-
Bug
-
Resolution: Not an Issue
-
P4
-
repo-valhalla
Attached test fails verification:
javac --enable-preview -source 25 --add-exports java.base/jdk.internal.vm.annotation=ALL-UNNAMED --add-exports java.base/jdk.internal.value=ALL-UNNAMED Test.java && java --enable-preview --add-exports java.base/jdk.internal.vm.annotation=ALL-UNNAMED --add-exports java.base/jdk.internal.value=ALL-UNNAMED -Xint -cp . Test
Note: Test.java uses preview features of Java SE 25.
Note: Recompile with -Xlint:preview for details.
Error: Unable to initialize main class Test
Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
Test.<init>()V @17: invokespecial
Reason:
Type uninitializedThis (current frame, stack[3]) is not assignable to 'Test'
Current Frame:
bci: @17
flags: { flagThisUninit }
locals: { uninitializedThis }
stack: { uninitializedThis, uninitialized 12, uninitialized 12, uninitializedThis }
Bytecode:
0000000: 2abb 0001 59b7 0003 b500 072a bb00 0d59
0000010: 2ab7 000f b500 122a b700 16b1
Bytecode looks like this:
public Test();
descriptor: ()V
flags: (0x0001) ACC_PUBLIC
Code:
stack=4, locals=1, args_size=1
0: aload_0
1: new #1 // class Test$MyValue1
4: dup
5: invokespecial #3 // Method Test$MyValue1."<init>":()V
8: putfield #7 // Field field:LTest$MyValue1;
11: aload_0
12: new #13 // class Test$MyValue2
15: dup
16: aload_0
17: invokespecial #15 // Method Test$MyValue2."<init>":(LTest;)V
20: putfield #18 // Field field2:LTest$MyValue2;
23: aload_0
24: invokespecial #22 // Method java/lang/Object."<init>":()V
27: return
Making MyValue2 static solves the issue.
Update:
I found an even simpler test (Test2.java) without value classes.
Error: Unable to initialize main class Test2
Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
Test2.<init>()V @13: getfield
Reason:
Type uninitializedThis (current frame, stack[1]) is not assignable to 'Test2'
Current Frame:
bci: @13
flags: { flagThisUninit }
locals: { uninitializedThis }
stack: { uninitializedThis, uninitializedThis }
Bytecode:
0000000: 2abb 0001 59b7 0003 b500 072a 2ab4 0007
0000010: b500 0d2a b700 10b1
javac --enable-preview -source 25 --add-exports java.base/jdk.internal.vm.annotation=ALL-UNNAMED --add-exports java.base/jdk.internal.value=ALL-UNNAMED Test.java && java --enable-preview --add-exports java.base/jdk.internal.vm.annotation=ALL-UNNAMED --add-exports java.base/jdk.internal.value=ALL-UNNAMED -Xint -cp . Test
Note: Test.java uses preview features of Java SE 25.
Note: Recompile with -Xlint:preview for details.
Error: Unable to initialize main class Test
Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
Test.<init>()V @17: invokespecial
Reason:
Type uninitializedThis (current frame, stack[3]) is not assignable to 'Test'
Current Frame:
bci: @17
flags: { flagThisUninit }
locals: { uninitializedThis }
stack: { uninitializedThis, uninitialized 12, uninitialized 12, uninitializedThis }
Bytecode:
0000000: 2abb 0001 59b7 0003 b500 072a bb00 0d59
0000010: 2ab7 000f b500 122a b700 16b1
Bytecode looks like this:
public Test();
descriptor: ()V
flags: (0x0001) ACC_PUBLIC
Code:
stack=4, locals=1, args_size=1
0: aload_0
1: new #1 // class Test$MyValue1
4: dup
5: invokespecial #3 // Method Test$MyValue1."<init>":()V
8: putfield #7 // Field field:LTest$MyValue1;
11: aload_0
12: new #13 // class Test$MyValue2
15: dup
16: aload_0
17: invokespecial #15 // Method Test$MyValue2."<init>":(LTest;)V
20: putfield #18 // Field field2:LTest$MyValue2;
23: aload_0
24: invokespecial #22 // Method java/lang/Object."<init>":()V
27: return
Making MyValue2 static solves the issue.
Update:
I found an even simpler test (Test2.java) without value classes.
Error: Unable to initialize main class Test2
Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
Test2.<init>()V @13: getfield
Reason:
Type uninitializedThis (current frame, stack[1]) is not assignable to 'Test2'
Current Frame:
bci: @13
flags: { flagThisUninit }
locals: { uninitializedThis }
stack: { uninitializedThis, uninitializedThis }
Bytecode:
0000000: 2abb 0001 59b7 0003 b500 072a 2ab4 0007
0000010: b500 0d2a b700 10b1