[jdk17] RFR: 8268663: Crash when guards contain boolean expression

Vicente Romero vromero at openjdk.java.net
Mon Jun 14 15:01:04 UTC 2021


On Mon, 14 Jun 2021 13:23:25 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> When Flow analyzes boolean expressions, (un-)initialized are split into (un-)initialized when true and when false. When analyzing guarded patterns, we need to handle these split values. As the only way the case's body/statements can be executed is if the case's pattern matches, we need to use the initialized values when true.

test/langtools/tools/javac/patterns/Guards.java line 98:

> 96:         Object o2 = "";
> 97:         switch (o) {
> 98:             case Integer i && i == 0 && i < 1 && o2 instanceof String s: o = s + String.valueOf(i); return "true";

hi, I would recommend adding more tests with `||` in the condition, and with more than one case in the switch with conditions

-------------

PR: https://git.openjdk.java.net/jdk17/pull/41


More information about the compiler-dev mailing list