Description
Beside just increment of bytecode version JDK 11 might have real changes in bytecode: for example there might be addition of new entries into constant pool - as of today (21/03/18) JEP 309 is scheduled on JDK 11. And we should keep an eye on JEP 12 as it might change meaning of a minor segement of bytecode version. Also AFAIK JEP 181 some time ago was scheduled on 11 and earlier even on 10.
So we can't guarantee and hence support correct instrumentation of class files with bytecode version 55 until ASM library with support for this version not released.
❗️⚠️ 🚧🔥 TEXT BELOW IS IN PROCESS OF EDITING 🔥🚧⚠️ ❗️
However in order to allow collection of coverage for bytecode version lower than 55 when executed under JDK 11, instrumentation of only one class with bytecode version 55 will be enough - JDK class used by ModifiedSystemClassRuntime
. As of today the only change in this class between JDK 10 GA and JDK 11 EA build 5 is
$ jmod extract --dir 10 openjdk-10/jmods/java.base.jmod
$ jmod extract --dir 11 openjdk-11-ea+5_linux-x64_bin/jmods/java.base.jmod
$ xxd 10/classes/java/lang/UnknownError.class > 10.hex
$ xxd 11/classes/java/lang/UnknownError.class > 11.hex
$ diff 10.hex 11.hex
1c1
< 0000000: cafe babe 0000 0036 001a 0a00 0400 160a .......6........
---
> 0000000: cafe babe 0000 0037 001a 0a00 0400 160a .......7........
So we can guarantee its safe instrumentation by checking its checksum. Or even stronger - by checking that all bytes are expected ones.
Change in class file between 9.0.4 and 10:
$ jmod extract --dir 9.0.4 openjdk-9.0.4/jmods/java.base.jmod
$ xxd 9.0.4/classes/java/lang/UnknownError.class > 9.hex
$ diff 9.0.4.hex 10.hex
1c1
< 0000000: cafe babe 0000 0035 001a 0a00 0400 160a .......5........
---
> 0000000: cafe babe 0000 0036 001a 0a00 0400 160a .......6........
While there is no change in source file between 8u152 and 9.0.4, changes in class file are more significant:
$ unzip jdk-8u152/jre/lib/rt.jar -d 8u152
$ javap -v -p 8u152/java/lang/UnknownError.class > 8u152.txt
$ javap -v -p 9.0.4/classes/java/lang/UnknownError.class > 9.0.4.txt
$ diff 8u152.txt 9.txt | tail -n 9
48a54,56
> LocalVariableTable:
> Start Length Slot Name Signature
> 0 5 0 this Ljava/lang/UnknownError;
61a70,73
> LocalVariableTable:
> Start Length Slot Name Signature
> 0 6 0 this Ljava/lang/UnknownError;
> 0 6 1 s Ljava/lang/String;
https://bugs.openjdk.java.net/browse/JDK-8145188
$ jimage extract --dir=10-jre jre-10/lib/modules
$ javap -v -p 10-jre/java.base/java/lang/UnknownError.class > 10-jre.txt
$ javap -v -p 10/classes/java/lang/UnknownError.class > 10-jdk.txt
$ $ diff 10-jdk.txt 10-jre.txt | tail -25
49c40
< 1: invokespecial #1 // Method java/lang/VirtualMachineError."<init>":()V
---
> 1: invokespecial #12 // Method java/lang/VirtualMachineError."<init>":()V
51,56d41
< LineNumberTable:
< line 43: 0
< line 44: 4
< LocalVariableTable:
< Start Length Slot Name Signature
< 0 5 0 this Ljava/lang/UnknownError;
65c50
< 2: invokespecial #2 // Method java/lang/VirtualMachineError."<init>":(Ljava/lang/String;)V
---
> 2: invokespecial #15 // Method java/lang/VirtualMachineError."<init>":(Ljava/lang/String;)V
67,73d51
< LineNumberTable:
< line 53: 0
< line 54: 5
< LocalVariableTable:
< Start Length Slot Name Signature
< 0 6 0 this Ljava/lang/UnknownError;
< 0 6 1 s Ljava/lang/String;
75d52
< SourceFile: "UnknownError.java"
Metadata
Metadata
Assignees
Type
Projects
Status