-
Bug
-
Resolution: Fixed
-
P4
-
22
-
b02
/// Test case
import java.io.Serializable;
public class BytecodeTracerTest {
public static class Unlinked implements Serializable {
public String toString() {
return "Unlinked" + this.hashCode();
}
}
public static void main(String args[]) {
System.out.println("num args = " + args.length);
}
public Serializable cast(Unlinked f) {
// Verifying this method causes the "Unlinked" class to be loaded. However
// the "Unlinked" class is never used during the execution of
// BytecodeTracerTest.main(), so it is not linked by HotSpot.
return f;
}
}
// Modify exit_globals() in init.cpp to be:
+extern "C" JNIEXPORT void findclass(const char* class_name_pattern, int flags);
void exit_globals() {
static bool destructorsCalled = false;
+ if (UseNewCode) {
+ findclass("BytecodeTracerTest", 0xff);
+ findclass("BytecodeTracerTest$Unlinked", 0xff);
+ }
// Output: (debug VM)
$ java -XX:+UseNewCode -cp ~/tmp BytecodeTracerTest
0x00007f3aa8400398 static method main : ([Ljava/lang/String;)V
0x00007f3aa8400380 0 getstatic 7 <java/lang/System.out/Ljava/io/PrintStream;>
0x00007f3aa8400383 3 fast_aload_0
0x00007f3aa8400384 4 arraylength
0x00007f3aa8400385 5 invokedynamic 1 <java/lang/Object.<init>()V> <<<<< WRONG
0x00007f3aa840038a 10 invokevirtual 17 <java/io/PrintStream.println(Ljava/lang/String;)V>
0x00007f3aa840038d 13 return
import java.io.Serializable;
public class BytecodeTracerTest {
public static class Unlinked implements Serializable {
public String toString() {
return "Unlinked" + this.hashCode();
}
}
public static void main(String args[]) {
System.out.println("num args = " + args.length);
}
public Serializable cast(Unlinked f) {
// Verifying this method causes the "Unlinked" class to be loaded. However
// the "Unlinked" class is never used during the execution of
// BytecodeTracerTest.main(), so it is not linked by HotSpot.
return f;
}
}
// Modify exit_globals() in init.cpp to be:
+extern "C" JNIEXPORT void findclass(const char* class_name_pattern, int flags);
void exit_globals() {
static bool destructorsCalled = false;
+ if (UseNewCode) {
+ findclass("BytecodeTracerTest", 0xff);
+ findclass("BytecodeTracerTest$Unlinked", 0xff);
+ }
// Output: (debug VM)
$ java -XX:+UseNewCode -cp ~/tmp BytecodeTracerTest
0x00007f3aa8400398 static method main : ([Ljava/lang/String;)V
0x00007f3aa8400380 0 getstatic 7 <java/lang/System.out/Ljava/io/PrintStream;>
0x00007f3aa8400383 3 fast_aload_0
0x00007f3aa8400384 4 arraylength
0x00007f3aa8400385 5 invokedynamic 1 <java/lang/Object.<init>()V> <<<<< WRONG
0x00007f3aa840038a 10 invokevirtual 17 <java/io/PrintStream.println(Ljava/lang/String;)V>
0x00007f3aa840038d 13 return
- relates to
-
JDK-8309811 BytecodePrinter cannot handle unlinked classes
- Resolved