-
Bug
-
Resolution: Fixed
-
P4
-
17, 20, 21, 22
-
b15
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8316103 | 21.0.2 | Jan Lahoda | P4 | Resolved | Fixed | b02 |
A DESCRIPTION OF THE PROBLEM :
Using JDK 20.0.2, a switch expression containing a synchronized block will cause a VerifyError
REGRESSION : Last worked in version 20.0.2
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Here is the code that reproduces the problem:
// an instance field
private final String content;
// a constructor for a Name class that implements javax.lang.model.element.Name (not sure this matters)
public Name(final CharSequence cs) {
super();
this.content = switch (cs) {
case null -> "";
case String s -> s;
case Name n -> n.content;
case javax.lang.model.element.Name n -> {
synchronized (CompletionLock.monitor()) {
yield n.toString();
}
}
default -> cs.toString();
};
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Successful compilation
ACTUAL -
java.lang.VerifyError:
Stack map does not match the one at exception handler 104
---------- BEGIN SOURCE ----------
See reproduction steps
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't use switch expressions
FREQUENCY : always
Using JDK 20.0.2, a switch expression containing a synchronized block will cause a VerifyError
REGRESSION : Last worked in version 20.0.2
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Here is the code that reproduces the problem:
// an instance field
private final String content;
// a constructor for a Name class that implements javax.lang.model.element.Name (not sure this matters)
public Name(final CharSequence cs) {
super();
this.content = switch (cs) {
case null -> "";
case String s -> s;
case Name n -> n.content;
case javax.lang.model.element.Name n -> {
synchronized (CompletionLock.monitor()) {
yield n.toString();
}
}
default -> cs.toString();
};
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Successful compilation
ACTUAL -
java.lang.VerifyError:
Stack map does not match the one at exception handler 104
---------- BEGIN SOURCE ----------
See reproduction steps
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't use switch expressions
FREQUENCY : always
- backported by
-
JDK-8316103 VerifyError when switch statement used with synchronized block
-
- Resolved
-