Skip to content

Add support for Java 9+

Matteo Basso requested to merge mbasso/disl:feature/java_9 into devel

This Merge Request aims to update DiSL in order to support the latest versions of Java, such as Java 9, 10, 11, 12 and 13. In the last case, some warnings (-noverify has been deprecated) appears but DiSL works fine.

Here is a list of changes and new implementations that have been done to achieve this goal. Breaking changes addressed by this Merge Request are available at the following link: https://www.oracle.com/technetwork/java/javase/9-relnote-issues-3704069.html.

  • Changed ant default Java source and target to 9. jvmti and jni headers have been updated.
  • Updated ASM to the latest version, 7.2.
  • Replaced javah, which has been removed in Java 9, with javac -h.
  • Fixed codeflags generation introducing @Native annotation.
  • Fixed ShadowVM tests: removed ASM specific pseudo access flags not defined in the JVM specification. They made some tests fail when comparing ShadowField and Field modifiers since Object.finalize has been deprecated.
  • Updated Google Protobuf (renamed to protobuf-javalite) to suppress illegal access warnings.
  • As the release notes underline: "The default behavior has changed so that the ClassFileLoadHook event is not sent during the primordial phase". This means that some classes are not processed as before since the callback of this event is the one responsible to instrument the code. For this reason, two actions has been performed:
    • Preloaded classes are sent to DiSL Server and DiSL Evaluation Server to be retransformed when the VMInit event is called. It ensures the instrumentation of every class even though the event is not called as before.
    • During the retransformation fields must not be added, removed or renamed. This is in contrast with the functionality provided by the @ThreadLocal annotation, which adds new fields to the class to work. To avoid this problem the instrumented Thread is generated by the DiSL server before the starting of the client, which will use directly the right version.
  • -Xbootclasspath/p has been removed and replaced with a new option --patch-module. Building and testing procedures have been modified accordingly (Thread class).
  • Because of the new module system and the removal of -Xbootclasspath/p option, adjustments to the BypassCheck class visibility needed to be done. It is now patched together with the new Thread class and the agent is responsible to make it visible to all other modules in the application during class file loading (using AddModuleExports).
  • Python script has been updated to use the new command-line options (--patch-module) and run DiSL in the right way (also waiting for Thread creation by DiSL server).

Continuous integration has been modified to use Java 9 with OpenJDK, since the old image has no updates available and Oracle JDK has been relicensed. The new image is implemented in the Dockerfile and has been published on the docker hub (mbasso/disl-ci) instead of the gitlab registry (gitlab.ow2.org:4567/disl/disl/disl-ci). This is because access and publish permissions are needed, so external collaborators cannot do it.

Changes have been tested on OpenJDK and Oracle JDK.

Please note that this new version of DiSL cannot be used with Java 8 and previous versions due to the introduction of the module system and command-line changes.

Edited by Matteo Basso

Merge request reports