Utility for checking API compatibility with JDK

Stuart Ballard sballard at netreach.net
Mon Jun 12 08:20:20 PDT 2000


Hi,

I'm attaching a Java program and perl script I wrote to test
compatibility between the JDK and free versions. It's in its early
stages but from my testing so far, the results are already interesting.
Consider both the attached files to be under the GPL (sorry about the
lack of legal headers).

WARNING:
IANAL and I don't know the legal implications of this program. I don't
know of any reason why it shouldn't be legitimate for any free program
to use; when running under the JDK it only uses public APIs and only
extracts information that's in the public documentation anyway. But I
suggest waiting until there's some sort of consensus on whether this is
legitimate for your project before potentially contaminating yourself by
finding out the results.

USAGE:
To use the program (I'll tack on -jdk or -free to command names so you
know which one I mean. "-free" is obviously kaffe or japhar or whatever
implementation you are testing).

$ java-jdk11 net.wuffies.japi.Japize -f $JAVAHOME/lib/classes.zip java >
jdk11.japi
$ grep -v '^java\.awt\.peer' jdk11.japi | grep -v
'^java\.text\.resources' > jdk11real.japi
[These are public packages in the java hierarchy but aren't in the
documented API]
$ java-free net.wuffies.japi.Japize -f $FREEHOME/Klasses.jar java >
free.japi
[If you're using kaffe, also do
$ java-free net.wuffies.japi.Japize -f $FREEHOME/rmi.jar java >>
free.japi
]
$ japicompat.pl jdk11real.japi free.japi

Note that this program doesn't do "symmetric" testing, but rather tests
for "backward compatibility". It's approximately checking for a "subset"
relation. Since most free implementations lie somewhere between jdk1.1
and jdk1.2, the "interesting" questions to ask are:

japicompat.pl jdk11.japi free.japi
japicompat.pl free.japi jdk12.japi

Of course, to see how well Sun kept to their own rules for backward
compatibility...
japicompat.pl jdk11.japi jdk12.japi
is also kind of interesting. I haven't tried this yet.

So far, I've only tested on kaffe against jdk11. There's a workaround in
the code for the bug that I recently posted on the kaffe list; every
time that workaround is needed, a "!" or an "M" appear on stderr (I
don't know why the "M"s ever happen... this may be another bug. See the
code).

I'll post my results if there's a consensus that it's legal to do so.

BUGS:
I'm sure there are lots. The commenting stinks, for a start; I'll try to
improve this over the next couple of days. Also, I need to go over the
details of "Binary compatibility" as defined in the JLS to make sure
that I'm testing for exactly everything I should be. One known issue is
that the figuring out of what interfaces a class supports is limited to
checking the class itself rather than its superclasses; I have a fix for
that mostly written but not integrated.

NOTES:
I haven't ever succeeded in getting Japhar+classpath to actually run, so
this is 100% untested on that combination. It requires basic
functionality from java.util.zip, which I'm not sure is fully integrated
into classpath yet; you may need to add this by hand.

Although it takes a jar file as an argument, it doesn't actually load
classes from that jar; it just looks at the filenames, trims off the
".class", substitutes "." for "/" and then uses Class.forName(). I
didn't use an URLClassLoader because I needed to run it on 1.1.

Although Japize itself can't run on 1.0, it might be possible to use a
perl script on the results of javap to get a jdk10.japi file. I'm not
particularly interested in doing this in the short term; 1.0
compatibility is more-or-less irrelevant these days. The only interest
this would hold would be to compare jdk10.japi with jdk11.japi...

Depending on the consensus of legality, this might be interesting to
include into Mauve. I haven't cc'd that list because I'm not on it.

Have fun with this; patches are welcome :)

Stuart.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: japicompat.pl
Type: application/octet-stream
Size: 5541 bytes
Desc: not available
Url : http://kaffe.org/pipermail/kaffe/attachments/20000612/3859d395/attachment-0006.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Japize.java
Type: application/octet-stream
Size: 5891 bytes
Desc: not available
Url : http://kaffe.org/pipermail/kaffe/attachments/20000612/3859d395/attachment-0007.obj 


More information about the kaffe mailing list