-
Bug
-
Resolution: Fixed
-
P3
-
20, 21
-
b11
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8303347 | 20.0.2 | Jan Lahoda | P3 | Resolved | Fixed | b01 |
JDK-8303247 | 20.0.1 | Jan Lahoda | P3 | Resolved | Fixed | b08 |
Consider code like:
---
public class NullPatterns {
public static void main(String[] args) {
switch (new R(null)) {
case R(Object o) when o == null -> {} //correct
case R(Object o) -> throw new AssertionError("Incorrect case!");
};
}
record R(Object o) {}
}
---
Running this leads to incorrect outcome:
---
$ java --enable-preview --source 21 NullPatterns.java
Note: NullPatterns.java uses preview features of Java SE 21.
Note: Recompile with -Xlint:preview for details.
Exception in thread "main" java.lang.AssertionError: Incorrect case!
at NullPatterns.main(NullPatterns.java:6)
--
---
public class NullPatterns {
public static void main(String[] args) {
switch (new R(null)) {
case R(Object o) when o == null -> {} //correct
case R(Object o) -> throw new AssertionError("Incorrect case!");
};
}
record R(Object o) {}
}
---
Running this leads to incorrect outcome:
---
$ java --enable-preview --source 21 NullPatterns.java
Note: NullPatterns.java uses preview features of Java SE 21.
Note: Recompile with -Xlint:preview for details.
Exception in thread "main" java.lang.AssertionError: Incorrect case!
at NullPatterns.main(NullPatterns.java:6)
--
- backported by
-
JDK-8303247 Incorrect desugaring of null-allowed nested patterns
-
- Resolved
-
-
JDK-8303347 Incorrect desugaring of null-allowed nested patterns
-
- Resolved
-
- duplicates
-
JDK-8304863 Nested record deconstruction cause bytecode error
-
- Closed
-
- links to
-
Commit openjdk/jdk20u/db260e59
-
Commit openjdk/jdk/dc55a7fc
-
Review openjdk/jdk20u/7
-
Review openjdk/jdk/12572
(2 links to)