lvc/japi-compliance-checker

Support for Java 9

lvc opened this issue · 4 comments

lvc commented

For now the tool checks classes of a project by extracting *.jar files to /tmp/XYZ directory and disassembling *.class files by javap. This works for Java 1-8.

In Java 9 we need to support modules. The tool should be able to compare modules instead of *.jar files.

One can list classes in the module file by this command:

jimage list ./modules

...
/jdk.zipfs/jdk/nio/zipfs/ZipFileSystem.class
/jdk.zipfs/jdk/nio/zipfs/ZipFileSystemProvider.class
/jdk.zipfs/jdk/nio/zipfs/ZipInfo.class
/jdk.zipfs/jdk/nio/zipfs/ZipPath$1.class
/jdk.zipfs/jdk/nio/zipfs/ZipPath$2.class
/jdk.zipfs/jdk/nio/zipfs/ZipPath.class
/jdk.zipfs/jdk/nio/zipfs/ZipUtils.class
/jdk.zipfs/module-info.class
...

And then we can run javap against one of them:

javap jrt:/jdk.zipfs/jdk/nio/zipfs/ZipInfo.class

Compiled from "ZipInfo.java"
public class jdk.nio.zipfs.ZipInfo {
  public jdk.nio.zipfs.ZipInfo();
  public static void main(java.lang.String[]) throws java.lang.Throwable;
  static void print(java.lang.String, java.lang.Object...);
  static void printLOC(byte[]);
  static void printCEN(byte[], int);
  static long locoff(byte[], int);
  static void printExtra(byte[], int, int);
}

So we just need to replace the extracting of jar by listing the module and add jrt:/ prefix to class paths.

Hi!

This can go a bit more complicated.
The first hack really should be just add *.jmod behind *.jar and *.class listing and treat it as usually. And this step should remain valid run.
On addition, new runlevel of module compatibility should be introduced - modules contain module descriptor which may hide (and usually hides a lot) apis to rest of the world. One may expect the apichecker will warn me if module-desrptor sends my public class behind all accessibility.

/me looking forward for simple .jmod fix. Second is just hint to think about

lvc commented

@judovana,

Do you know libraries that switched to a new modular architecture? I need an example to fix this issue.

Thank you.

lvc commented

Fixed by commit 5e5989e. For now you can compare Java 9 modules by:

japi-compliance-checker OLD.jmod NEW.jmod

Reports for OpenJDK 9: https://abi-laboratory.pro/java/tracker/timeline/openjdk/
Reports for JRE 9: https://abi-laboratory.pro/java/tracker/timeline/jre/

The reports are generated by the latest versions of the japi-monitor and japi-tracker tools.

Thanks.