How to identify a missing method (Binary Compatibility) in a JAR statically

风格不统一 提交于 2019-11-28 05:27:22

japi-compliance-checker - backward API/ABI compatibility checker for a Java library:

japi-compliance-checker -lib NAME -old OLD.jar -new NEW.jar

sigtest - Oracle's SigTest signature testing and API conformance tool

japitools - test for compatibility between Java APIs

japi-checker - a java API backward compatibility checker which works at binary level

revapi - API analysis and change tracking tool

or manually using javap decompiler:

javap OLD.class > OLD.txt
javap NEW.class > NEW.txt
diff -rNau OLD.txt NEW.txt > CHANGES.txt

Clirr - checks Java libraries for binary and source compatibility with older releases:

java -jar clirr-core-0.6-uber.jar -o OLD.jar -n NEW.jar

Revapi can do the job, too. It is easy to incorporate it into maven builds, which is not your case obviously, but might be of interest to others.

It can also check arbitrary sets of jars using its standalone mode.

japicmp is another tool for checking binary compatibility. It is available as standalone command line tool or as maven plugin.

Michael Donohue

There is a tool by the name of Animal Sniffer that allows you to extract a signature for an API. Then it can statically verify that users of the API stick to the signature, and it can statically verify that implementors of the API have everything implemented. I think this would solve your problem nicely.

You can download the jar for Animal Sniffer from the codehaus maven repository: http://repo1.maven.org/maven2/org/codehaus/mojo/animal-sniffer/

Do you need a to check a specific class or a generic tool for comparing jar's? If it's for 1 class, simply load the class in a custom class loader, check the methods signature by using reflection and that's it. If you need it for many JAR's/Classes this will be too much work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!