-
Bug
-
Resolution: Fixed
-
P4
-
22
-
b04
BytecodePrinter always uses Bytes::get_native_u2/u4 to read the index of bytecodes such as the field and invoke bytecodes. However, if this class is not yet linked, the indices should be read using Bytes::get_Java_u2/u4
(x64 and most supported CPUs are little endian, so the "java" and "native" byte ordering are reversed.)
https://github.com/openjdk/jdk/blob/16c3d53b1bb60b1c1570731041f564bf13b45098/src/hotspot/share/interpreter/bytecodeTracer.cpp#L66-L67
This is not a problem for -XX:+TraceBytecodes, which only traces classes that have been linked. However, we'd get bad output when calling Method::print_codes_on() for unlinked classes.
==========================
Test case is the same as inJDK-8309808
// Output: (debug VM)
$ java -XX:+UseNewCode -cp ~/tmp BytecodeTracerTest
[....]
[ 0] 0x0000000801000a18 class BytecodeTracerTest$Unlinked loader data: 0x00007f3ae0273a40 for instance a 'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x00000007ffce70a8}
0x00007f3aa8400888 method <init> : ()V
0x00007f3aa8400880 0 aload_0
0x00007f3aa8400881 1 invokespecial CP[65792] not in CP <<<<<
0x00007f3aa8400884 4 return
0x00007f3aa8400940 method toString : ()Ljava/lang/String;
0x00007f3aa8400930 0 aload_0
0x00007f3aa8400931 1 invokevirtual CP[67328] not in CP <<<<<
0x00007f3aa8400934 4 invokedynamic CP[62719] not in CP <<<<<
0x00007f3aa8400939 9 areturn
(x64 and most supported CPUs are little endian, so the "java" and "native" byte ordering are reversed.)
https://github.com/openjdk/jdk/blob/16c3d53b1bb60b1c1570731041f564bf13b45098/src/hotspot/share/interpreter/bytecodeTracer.cpp#L66-L67
This is not a problem for -XX:+TraceBytecodes, which only traces classes that have been linked. However, we'd get bad output when calling Method::print_codes_on() for unlinked classes.
==========================
Test case is the same as in
// Output: (debug VM)
$ java -XX:+UseNewCode -cp ~/tmp BytecodeTracerTest
[....]
[ 0] 0x0000000801000a18 class BytecodeTracerTest$Unlinked loader data: 0x00007f3ae0273a40 for instance a 'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x00000007ffce70a8}
0x00007f3aa8400888 method <init> : ()V
0x00007f3aa8400880 0 aload_0
0x00007f3aa8400881 1 invokespecial CP[65792] not in CP <<<<<
0x00007f3aa8400884 4 return
0x00007f3aa8400940 method toString : ()Ljava/lang/String;
0x00007f3aa8400930 0 aload_0
0x00007f3aa8400931 1 invokevirtual CP[67328] not in CP <<<<<
0x00007f3aa8400934 4 invokedynamic CP[62719] not in CP <<<<<
0x00007f3aa8400939 9 areturn
- relates to
-
JDK-8309808 BytecodeTracer prints wrong BSM for invokedynamic
-
- Resolved
-