Skip to content

Commit b7cdf27

Browse files
committed
classfile reader: allow CONSTANT_Dynamic in constant pool
1 parent 6c0a9bc commit b7cdf27

4 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ abstract class ClassfileParser(reader: ReusableInstance[ReusableDataReader]) {
212212
case CONSTANT_METHODHANDLE => in skip 3
213213
case CONSTANT_FIELDREF | CONSTANT_METHODREF | CONSTANT_INTFMETHODREF => in skip 4
214214
case CONSTANT_NAMEANDTYPE | CONSTANT_INTEGER | CONSTANT_FLOAT => in skip 4
215-
case CONSTANT_INVOKEDYNAMIC => in skip 4
215+
case CONSTANT_DYNAMIC | CONSTANT_INVOKEDYNAMIC => in skip 4
216216
case CONSTANT_LONG | CONSTANT_DOUBLE => in skip 8 ; i += 1
217217
case _ => errorBadTag(in.bp - 1)
218218
}

src/reflect/scala/reflect/internal/ClassfileConstants.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ object ClassfileConstants {
8181
final val CONSTANT_NAMEANDTYPE = 12
8282
final val CONSTANT_METHODHANDLE = 15
8383
final val CONSTANT_METHODTYPE = 16
84+
final val CONSTANT_DYNAMIC = 17
8485
final val CONSTANT_INVOKEDYNAMIC = 18
8586
final val CONSTANT_MODULE = 19
8687
final val CONSTANT_PACKAGE = 20

test/files/pos/t12396/A_1.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// javaVersion: 21+
2+
3+
public class A_1 {
4+
public int f(Object s) {
5+
switch(s) {
6+
case Res.R -> {
7+
return 1;
8+
}
9+
default -> {
10+
return 3;
11+
}
12+
}
13+
}
14+
static enum Res {
15+
R
16+
}
17+
}

test/files/pos/t12396/B_2.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// javaVersion: 21+
2+
3+
class B {
4+
def bar = (new A_1).f(null)
5+
}

0 commit comments

Comments
 (0)