-
Notifications
You must be signed in to change notification settings - Fork 1.1k
"bad constant pool tag 17" when using a library compiled using Java 21 #19527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It turns out the problem is with switch-with-pattern-matching, which was stabilised in Java 21. After converting all switch blocks in the java library, specifially in the switch (sendResult) {
case SendResult.AWAITED -> {
// the thread was suspended and then resumed by a receiver or by buffer expansion
// not clearing the previous pointer, because of the buffering possibility
return null;
}
case SendResult.BUFFERED -> {
// a receiver is coming, or we are in buffer
// similarly as above, not clearing the previous pointer
return null;
}
case SendResult.RESUMED -> {
// we resumed a receiver - we can be sure that R > s
segment.cleanPrev();
return null;
}
case SendResult.FAILED -> {
// the cell was broken (hence already processed by a receiver) or interrupted (also a receiver
// must have been there); in both cases R > s
segment.cleanPrev();
// trying again with a new cell
}
case SendResult.CLOSED -> {
// not cleaning the previous segments - the close procedure might still need it
return closedReason.get();
}
case StoredSelectClause ss -> {
// we stored a select instance - there's no matching receive, not clearing the previous segment
return ss;
}
default -> throw new IllegalStateException("Unexpected result: " + sendResult);
} to if-else chains: if (sendResult == SendResult.AWAITED) {
// the thread was suspended and then resumed by a receiver or by buffer expansion
// not clearing the previous pointer, because of the buffering possibility
return null;
} else if (sendResult == SendResult.BUFFERED) {
// a receiver is coming, or we are in buffer
// similarly as above, not clearing the previous pointer
return null;
} else if (sendResult == SendResult.RESUMED) {
// we resumed a receiver - we can be sure that R > s
segment.cleanPrev();
return null;
} else if (sendResult == SendResult.FAILED) {
// the cell was broken (hence already processed by a receiver) or interrupted (also a receiver
// must have been there); in both cases R > s
segment.cleanPrev();
// trying again with a new cell
} else if (sendResult == SendResult.CLOSED) {
// not cleaning the previous segments - the close procedure might still need it
return closedReason.get();
} else if (sendResult instanceof StoredSelectClause ss) {
// we stored a select instance - there's no matching receive, not clearing the previous segment
return ss;
} else {
throw new IllegalStateException("Unexpected result: " + sendResult);
} The original problem ("bad constant pool tag") goes away. Looking at javap's output of the unchanged
Each switch-with-pattern-matching gets an entry in bootstrap methods, referencing
Rather, it's some kind of reference to the enum (here, subsequent |
Good catch! Thanks for reporting. Scala 2 is affected as well, so I've opened scala/bug#12936 |
I think we should consider this a blocker for 2.12.19 and 2.13.13, so I'll attempt a fix there first, then forward-port to Dotty. |
Yes, this should be a blocker, library will try to publish --relase 8 with Java 21. I just upgraded all my systems and published all my internal jars built with Java 21 but with @adamw thanks |
Scala 2 PR: scala/scala#10675 |
forward-port of scala/scala#10675 and scala/scala#8595 references scala/bug#12396 and scala/bug#11635 fixes #19527 ("bad constant pool tag 17") also fixes unreported potential "bad constant pool tag 19" and "bad constant pool tag 20" errors
forward-port of scala/scala#10675 and scala/scala#8595 references scala/bug#12396 and scala/bug#11635 fixes scala#19527 ("bad constant pool tag 17") also fixes unreported potential "bad constant pool tag 19" and "bad constant pool tag 20" errors
forward-port of scala/scala#10675 and scala/scala#8595 references scala/bug#12396 and scala/bug#11635 fixes #19527 ("bad constant pool tag 17") also fixes unreported potential "bad constant pool tag 19" and "bad constant pool tag 20" errors
forward-port of scala/scala#10675 and scala/scala#8595 references scala/bug#12396 and scala/bug#11635 fixes scala#19527 ("bad constant pool tag 17") also fixes unreported potential "bad constant pool tag 19" and "bad constant pool tag 20" errors
forward-port of scala/scala#10675 and scala/scala#8595 references scala/bug#12396 and scala/bug#11635 fixes scala#19527 ("bad constant pool tag 17") also fixes unreported potential "bad constant pool tag 19" and "bad constant pool tag 20" errors [Cherry-picked 26852de][modified]
Using the following snippet:
Gives:
This is also reproducible using an SBT project, both with Scala 3.3.1, and 3.4.1-RC1-bin-20240122-ca18f4a-NIGHTLY. The error then is:
I'm not sure if I'm reading javap's output right, but doing
javap -v com.softwaremill.jox.Channel
, the constant pool is:Which looks quite ordinary.
Using the same library from a java maven-based project works just fine. Both for deploying jox, and testing the above I'm using
openjdk version "21.0.2" 2024-01-16
.The pom.xml and Channel.java are linked (to a specific commit, since they since changed to work around the problem).
The text was updated successfully, but these errors were encountered: