RFR: JDK-8214113: Switch expressions may have constant type and may be skipped during write (original) (raw)

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Wed Nov 21 17:39:12 UTC 2018


Looks good

Maurizio

On 21/11/2018 12:41, Jan Lahoda wrote:

Hi,

Consider switch expression produces only a single constant value, like: switch (expr) { default: counter++; break 1; } Then Attr.condType returns the type of the given constant value, and if that is a constant type, the type of the whole switch expression is a constant type. And Gen may then elide the whole switch expression, which is wrong, as it may contain side-effects, or all the other arms may the throwing an exception. The solution would be to simply call .baseType() on the result, but simply deleting the special case for a single output value should work as well, as the following condition should handle the single output value case well. Bug: https://bugs.openjdk.java.net/browse/JDK-8214113 Webrev: http://cr.openjdk.java.net/~jlahoda/8214113/webrev.00/ How does this look? Thanks, Jan



More information about the compiler-dev mailing list