Closed SethTisue closed 5 months ago
Reproducer
public class A {
int f(Object s) {
switch(s) {
case Res.R -> {
return 1;
}
default -> {
return 3;
}
}
}
static enum Res {
R
}
}
➜ sandbox javap -v A.class
...
#30 = Dynamic #1:#31 // #1:invoke:Ljava/lang/Enum$EnumDesc;
...
Dynamic
?
Where's 17?
Oh it was added in Java 11. https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-4.html#jvms-4.4-210.
Why did nobody tell us? 🙃
Seems like Scala missed the tag 17 and has a tag 2. Added in https://openjdk.org/jeps/309
That's entertaining; trivia on https://stackoverflow.com/a/63314177
It would be nice if ASM told us.
this is the Scala 2 equivalent of https://github.com/lampepfl/dotty/issues/19527, reported against Scala 3 by @adamw yesterday
the original report has some information about what kind of bytecode is involved — it’s
switch
on certain types, e.g. Javaenum
sScala 2 reproducer:
result: