やりたいこと
jarファイルのバイナリ互換性、ソース互換性をチェックする方法です。
前提条件
INSTALL参照。
- Perl 5.8以上
- JDK(javap, javac, jar, jmodコマンドを使うようです)。
概要
以下のツールを使います。
手順
インストール
Install参照。
sudo make install prefix=/usr
自分はDocker環境に閉じ込めました。
実行
Usage参照。
japi-compliance-checker OLD.jar NEW.jar
実行すると、以下のように出力されます。 レポートがHTMLで出力されるので、これを開くと、詳細が表示されます。
Preparing, please wait ...
Using Java 1.8.0_xx
Reading classes OLD ...
Reading classes NEW ...
Comparing classes ...
Creating compatibility report ...
Binary compatibility: 100%
Source compatibility: 100%
Total binary compatibility problems: 0, warnings: 0
Total source compatibility problems: 0, warnings: 0
Report: compat_reports/CM/OLD_to_NEW/compat_report.html
補足
ABI Laboratoryでは、 有名なライブラリについてチェックした結果も掲載されています。
面白いのが、Apache Commons Collections 3.2と4.0の比較で、 これは互換性が0%と表示されています。
その理由は、Apache Commons Collections 4.0はパッケージ名を変更したため、 互換性が無くなっているからです(逆に言えば、併用が可能)。
Collections – Release notes for version 4.0
To help with the migration to this new version, the package has changed to “org.apache.commons.collections4”, thus it is possible to have both commons-collections versions in the classpath.
マニュアル
- jar: まだありません。
- Java