-
Bug
-
Resolution: Fixed
-
P3
-
17
-
b28
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8269441 | 18 | Jan Lahoda | P3 | Resolved | Fixed | b04 |
JDK-8270628 | 17.0.1 | Jan Lahoda | P3 | Resolved | Fixed | b03 |
Consider code like:
---
public class Test {
public void test(Integer i) {
switch (i) {
case (Integer ii): break;
}
}
}
---
Compiling it leads to:
---
$ javac Test.java
An exception has occurred in the compiler (17-internal). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
java.lang.AssertionError
at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
at jdk.compiler/com.sun.tools.javac.comp.TransPatterns.handleSwitch(TransPatterns.java:275)
at jdk.compiler/com.sun.tools.javac.comp.TransPatterns.visitSwitch(TransPatterns.java:258)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCSwitch.accept(JCTree.java:1294)
---
The cause is that the source level/preview check is not being done on the parenthesized pattern in this case.
---
public class Test {
public void test(Integer i) {
switch (i) {
case (Integer ii): break;
}
}
}
---
Compiling it leads to:
---
$ javac Test.java
An exception has occurred in the compiler (17-internal). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
java.lang.AssertionError
at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
at jdk.compiler/com.sun.tools.javac.comp.TransPatterns.handleSwitch(TransPatterns.java:275)
at jdk.compiler/com.sun.tools.javac.comp.TransPatterns.visitSwitch(TransPatterns.java:258)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCSwitch.accept(JCTree.java:1294)
---
The cause is that the source level/preview check is not being done on the parenthesized pattern in this case.
- backported by
-
JDK-8269441 Parenthesized pattern is not guarded by source level check
-
- Resolved
-
-
JDK-8270628 Parenthesized pattern is not guarded by source level check
-
- Resolved
-