RFR (14): JDK-8236546: Yield with boolean expression and Object target type crashes javac.

Jan Lahoda jan.lahoda at oracle.com
Wed Jan 8 12:30:11 UTC 2020


Code like this crashes javac in Flow:

Object o = switch (s) { default -> s != null && s == s; };

The reason is that "s != null && s == s" will use split "when true" and 
"when false" (un/)initialized variables masks. But as the target type is 
not boolean, the merged (un/)initialized masks are needed. The real 
mistake is in using "scan" instead of "scanExpr" (which e.g. visitReturn 
does), so the proposal is to use "scanExpr" instead of "scan".

Proposed patch:
http://cr.openjdk.java.net/~jlahoda/8236546/webrev.00/

JBS: https://bugs.openjdk.java.net/browse/JDK-8236546

How does this look?

Thanks,
      Jan


More information about the compiler-dev mailing list