A potential JDK 20 bug
Tesla Zhang
ice1000kotlin at foxmail.com
Sat Aug 5 04:45:44 UTC 2023
Trying to run the following code with jdk 20 leads to java.lang.VerifyError:
public class Java20 {
sealed interface AST {}
record Lam(String name, AST ast) implements AST {}
record Var(String name) implements AST {}
record Pair(AST a, AST b) {}
static void test(AST x, AST y) {
System.out.println(switch (new Pair(x, y)) {
case Pair(Lam(var a, var b), var c) -> a + b + c;
case Pair(var a, Lam b) -> b.toString();
default -> "1919";
});
}
public static void main(String[] args) {
test(new Var("a"), new Var("b"));
}
}
The exception is:
Error: Unable to initialize main class com.intellij.bug.Java20 in module intellij.bug.reports
Caused by: java.lang.VerifyError: Bad local variable type
Exception Details:
Location:
com/intellij/bug/Java20.test(Lcom/intellij/bug/Java20$AST;Lcom/intellij/bug/Java20$AST;)V @192: aload
Reason:
Type top (current frame, locals[10]) is not assignable to reference type
Current Frame:
bci: @192
flags: { }
locals: { 'com/intellij/bug/Java20$AST', 'com/intellij/bug/Java20$AST', 'com/intellij/bug/Java20$Pair', integer, 'com/intellij/bug/Java20$Pair', top, top, top, top, 'com/intellij/bug/Java20$AST', top, 'com/intellij/bug/Java20$AST', integer }
stack: { 'java/io/PrintStream' }
Bytecode:
0000000: b200 07bb 000d 592a 2bb7 000f 59b8 0012
0000010: 574d 033e 2c1d ba00 1800 00ab 0000 00b2
0000020: 0000 0001 0000 0000 0000 0011 2c3a 0419
0000030: 04b6 001c 3a0b 0336 0c19 0b15 0cba 0020
0000040: 0000 aa00 0000 0086 ffff ffff 0000 0001
0000050: 0000 0056 0000 001a 0000 0056 190b c000
0000060: 213a 0519 04b6 0023 3a0d 190d 3a06 1905
0000070: b600 263a 0d19 0d3a 0719 05b6 002a 3a0d
0000080: 190d 3a08 1907 1908 b800 2d19 06b8 002d
0000090: ba00 3300 00a7 003d 190b 3a09 1909 c600
00000a0: 2219 04b6 0023 3a0d 190d c100 2199 000d
00000b0: 190d c000 213a 0aa7 0009 0536 0ca7 ff7c
00000c0: 190a b600 37a7 000d 043e a7ff 4a12 3aa7
00000d0: 0003 b600 3ca7 0011 4dbb 0044 592c b600
00000e0: 462c b700 47bf b1
Exception Handler Table:
bci [49, 52] => handler: 216
bci [101, 104] => handler: 216
bci [112, 115] => handler: 216
bci [123, 126] => handler: 216
bci [163, 166] => handler: 216
Stackmap Table:
full_frame(@20,{Object[#97],Object[#97],Object[#13],Integer},{Object[#61]})
same_locals_1_stack_item_frame(@44,Object[#61])
full_frame(@57,{Object[#97],Object[#97],Object[#13],Integer,Object[#13],Top,Top,Top,Top,Top,Top,Object[#97],Integer},{Object[#61]})
same_locals_1_stack_item_frame(@92,Object[#61])
same_locals_1_stack_item_frame(@152,Object[#61])
full_frame(@186,{Object[#97],Object[#97],Object[#13],Integer,Object[#13],Top,Top,Top,Top,Object[#97],Top,Object[#97],Integer},{Object[#61]})
same_locals_1_stack_item_frame(@192,Object[#61])
full_frame(@200,{Object[#97],Object[#97],Object[#13],Integer,Object[#13],Top,Top,Top,Top,Top,Top,Object[#97],Integer},{Object[#61]})
full_frame(@205,{Object[#97],Object[#97],Object[#13],Integer},{Object[#61]})
full_frame(@210,{Object[#97],Object[#97]},{Object[#61],Object[#46]})
same_locals_1_stack_item_frame(@216,Object[#66])
same_frame(@230)
Env:
openjdk version "20.0.2" 2023-07-18
OpenJDK Runtime Environment (build 20.0.2+10)
OpenJDK 64-Bit Server VM (build 20.0.2+10, mixed mode, sharing)
Best regards,
Tesla Zhang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20230805/bcb54673/attachment-0001.htm>
More information about the amber-dev
mailing list