ADDITIONAL SYSTEM INFORMATION :
Kernel: 6.1.0-37-amd64 arch: x86_64 bits: 64 compiler: gcc v: 12.2.0 Desktop: Cinnamon v: 6.4.8
tk: GTK v: 3.24.38 wm: muffin vt: 7 dm: LightDM v: 1.26.0 Distro: LMDE 6 Faye
base: Debian 12.1 bookworm
A DESCRIPTION OF THE PROBLEM :
if I include a switch with a pattern matching in the "`this` statement" of a record, the code builds correctly but I get an error at runtime with an error message related to bytecode. I made my tests with jdk 21 and jdk 24 : if the code is built with jdk 21, the issue happens but it does not happen if the code is built with jdk 24. I did not try with other versions.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Build (with a jdk 21) the code above (either in IDE or with `mvn clean install` or with javac)
2. Run it with jdk 21 (or 24) with a command like this : `java -classpath target/classes poc.java.TestSwitch`
3. You get the error message related to bytecode
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The console prints the following :
```
Bdto[s=a1, i=null]
```
ACTUAL -
The console prints this error message :
```
Exception in thread "main" java.lang.VerifyError: Stack map does not match the one at exception handler 180
Exception Details:
Location:
poc/java/TestSwitch$Bdto.<init>(Lpoc/java/TestSwitch$B;)V @180: astore_2
Reason:
Type uninitializedThis (current frame, locals[0]) is not assignable to 'poc/java/TestSwitch$Bdto' (stack map, locals[0])
Current Frame:
bci: @66
flags: { flagThisUninit }
locals: { uninitializedThis, 'poc/java/TestSwitch$B', 'poc/java/TestSwitch$A', integer, 'poc/java/TestSwitch$A$A1' }
stack: { 'java/lang/Throwable' }
Stackmap Frame:
bci: @180
flags: { }
locals: { 'poc/java/TestSwitch$Bdto', 'poc/java/TestSwitch$B' }
stack: { 'java/lang/Throwable' }
Bytecode:
0000000: 2a2b b600 1159 b800 1757 4d03 3e2c 1dba
0000010: 001d 0000 ab00 0000 0000 001c 0000 0002
0000020: 0000 0000 0000 0026 0000 0001 0000 003c
0000030: bb00 2159 0101 b700 23bf 2cc0 0026 3a04
0000040: 1904 b600 283a 0619 063a 0519 05a7 000a
0000050: 2cc0 002b 3a06 012b b600 1159 b800 1757
0000060: 4d03 3e2c 1dba 001d 0000 ab00 0000 001a
0000070: 0000 0002 0000 0000 0000 0024 0000 0001
0000080: 0000 002e bb00 2159 0101 b700 23bf 2cc0
0000090: 0026 3a04 01a7 0019 2cc0 002b 3a05 1905
00000a0: b600 2d36 0715 0736 0615 06b8 0030 b700
00000b0: 36a7 0011 4dbb 0021 592c b600 3b2c b700
00000c0: 23bf b1
Exception Handler Table:
bci [66, 69] => handler: 180
bci [160, 163] => handler: 180
Stackmap Table:
full_frame(@13,{UninitializedThis,Object[#18],Object[#77],Integer},{UninitializedThis})
same_locals_1_stack_item_frame(@48,UninitializedThis)
same_locals_1_stack_item_frame(@58,UninitializedThis)
same_locals_1_stack_item_frame(@80,UninitializedThis)
full_frame(@87,{UninitializedThis,Object[#18]},{UninitializedThis,Object[#79]})
full_frame(@99,{UninitializedThis,Object[#18],Object[#77],Integer},{UninitializedThis,Object[#79]})
full_frame(@132,{UninitializedThis,Object[#18],Object[#77],Integer},{UninitializedThis,Object[#79]})
full_frame(@142,{UninitializedThis,Object[#18],Object[#77],Integer},{UninitializedThis,Object[#79]})
full_frame(@152,{UninitializedThis,Object[#18],Object[#77],Integer},{UninitializedThis,Object[#79]})
full_frame(@174,{UninitializedThis,Object[#18]},{UninitializedThis,Object[#79],Object[#49]})
full_frame(@180,{Object[#8],Object[#18]},{Object[#57]})
same_frame(@194)
at poc.java.TestSwitch.main(TestSwitch.java:8)
```
Kernel: 6.1.0-37-amd64 arch: x86_64 bits: 64 compiler: gcc v: 12.2.0 Desktop: Cinnamon v: 6.4.8
tk: GTK v: 3.24.38 wm: muffin vt: 7 dm: LightDM v: 1.26.0 Distro: LMDE 6 Faye
base: Debian 12.1 bookworm
A DESCRIPTION OF THE PROBLEM :
if I include a switch with a pattern matching in the "`this` statement" of a record, the code builds correctly but I get an error at runtime with an error message related to bytecode. I made my tests with jdk 21 and jdk 24 : if the code is built with jdk 21, the issue happens but it does not happen if the code is built with jdk 24. I did not try with other versions.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Build (with a jdk 21) the code above (either in IDE or with `mvn clean install` or with javac)
2. Run it with jdk 21 (or 24) with a command like this : `java -classpath target/classes poc.java.TestSwitch`
3. You get the error message related to bytecode
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The console prints the following :
```
Bdto[s=a1, i=null]
```
ACTUAL -
The console prints this error message :
```
Exception in thread "main" java.lang.VerifyError: Stack map does not match the one at exception handler 180
Exception Details:
Location:
poc/java/TestSwitch$Bdto.<init>(Lpoc/java/TestSwitch$B;)V @180: astore_2
Reason:
Type uninitializedThis (current frame, locals[0]) is not assignable to 'poc/java/TestSwitch$Bdto' (stack map, locals[0])
Current Frame:
bci: @66
flags: { flagThisUninit }
locals: { uninitializedThis, 'poc/java/TestSwitch$B', 'poc/java/TestSwitch$A', integer, 'poc/java/TestSwitch$A$A1' }
stack: { 'java/lang/Throwable' }
Stackmap Frame:
bci: @180
flags: { }
locals: { 'poc/java/TestSwitch$Bdto', 'poc/java/TestSwitch$B' }
stack: { 'java/lang/Throwable' }
Bytecode:
0000000: 2a2b b600 1159 b800 1757 4d03 3e2c 1dba
0000010: 001d 0000 ab00 0000 0000 001c 0000 0002
0000020: 0000 0000 0000 0026 0000 0001 0000 003c
0000030: bb00 2159 0101 b700 23bf 2cc0 0026 3a04
0000040: 1904 b600 283a 0619 063a 0519 05a7 000a
0000050: 2cc0 002b 3a06 012b b600 1159 b800 1757
0000060: 4d03 3e2c 1dba 001d 0000 ab00 0000 001a
0000070: 0000 0002 0000 0000 0000 0024 0000 0001
0000080: 0000 002e bb00 2159 0101 b700 23bf 2cc0
0000090: 0026 3a04 01a7 0019 2cc0 002b 3a05 1905
00000a0: b600 2d36 0715 0736 0615 06b8 0030 b700
00000b0: 36a7 0011 4dbb 0021 592c b600 3b2c b700
00000c0: 23bf b1
Exception Handler Table:
bci [66, 69] => handler: 180
bci [160, 163] => handler: 180
Stackmap Table:
full_frame(@13,{UninitializedThis,Object[#18],Object[#77],Integer},{UninitializedThis})
same_locals_1_stack_item_frame(@48,UninitializedThis)
same_locals_1_stack_item_frame(@58,UninitializedThis)
same_locals_1_stack_item_frame(@80,UninitializedThis)
full_frame(@87,{UninitializedThis,Object[#18]},{UninitializedThis,Object[#79]})
full_frame(@99,{UninitializedThis,Object[#18],Object[#77],Integer},{UninitializedThis,Object[#79]})
full_frame(@132,{UninitializedThis,Object[#18],Object[#77],Integer},{UninitializedThis,Object[#79]})
full_frame(@142,{UninitializedThis,Object[#18],Object[#77],Integer},{UninitializedThis,Object[#79]})
full_frame(@152,{UninitializedThis,Object[#18],Object[#77],Integer},{UninitializedThis,Object[#79]})
full_frame(@174,{UninitializedThis,Object[#18]},{UninitializedThis,Object[#79],Object[#49]})
full_frame(@180,{Object[#8],Object[#18]},{Object[#57]})
same_frame(@194)
at poc.java.TestSwitch.main(TestSwitch.java:8)
```
- duplicates
-
JDK-8332106 VerifyError when using switch pattern in this(...) or super(...)
-
- Closed
-