Skip to content

Commit

Permalink
classfile reader: allow CONSTANT_Dynamic in constant pool
Browse files Browse the repository at this point in the history
forward-port of scala/scala#10675
references scala/bug#12396
fixes scala#19527
  • Loading branch information
SethTisue committed Jan 26, 2024
1 parent a9a75c1 commit 0bfacf0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ object ClassfileConstants {

inline val CONSTANT_METHODHANDLE = 15
inline val CONSTANT_METHODTYPE = 16
inline val CONSTANT_DYNAMIC = 17
inline val CONSTANT_INVOKEDYNAMIC = 18

// tags describing the type of a literal in attribute values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ object ClassfileParser {
in.skip(3)
case CONSTANT_FIELDREF | CONSTANT_METHODREF | CONSTANT_INTFMETHODREF
| CONSTANT_NAMEANDTYPE | CONSTANT_INTEGER | CONSTANT_FLOAT
| CONSTANT_INVOKEDYNAMIC =>
| CONSTANT_INVOKEDYNAMIC | CONSTANT_DYNAMIC =>
in.skip(4)
case CONSTANT_LONG | CONSTANT_DOUBLE =>
in.skip(8)
Expand Down
17 changes: 17 additions & 0 deletions tests/pos/t12396/A_1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// test: -jvm 21+

public class A_1 {
public int f(Object s) {
switch(s) {
case Res.R -> {
return 1;
}
default -> {
return 3;
}
}
}
static enum Res {
R
}
}
5 changes: 5 additions & 0 deletions tests/pos/t12396/B_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// test: -jvm 21+

class B {
def bar = (new A_1).f(null)
}

0 comments on commit 0bfacf0

Please sign in to comment.