Search code examples
javafieldcompatibilitymethod-signature

Tool to look for incompatabilities in method signatures / fields


I would like to be able to compare two versions of a class / library to determine whether there have been any changes that might break code that calls it. For example consider some class Foo that has a method in version a:

public String readWidget(Object widget, Object helper);

and in version b the method becomes:

public String readWidget(Object widget); //removed unnecessary helper object

or something similar in the case of a field:

version a: public static Object sharedFoo;
version b: static Object sharedFoo; //moved to package private for version b

I would like a tool that will flag these changes as potential incompatibilities (but ideally not the reverse i.e. increasing the visibility of a method). Now I know that I can do this via reflections, or by analyzing the output from javap, however it seems like there should be an existing tool (preferably non-commercial). So I wanted to see if anyone can recommend something before I make the mistake of rolling my own / reinventing the wheel unnecessarily.


Solution

  • Guava uses JDiff to report version changes, maybe you can find it useful, too?