RFR: 8314226: Series of colon-style fallthrough switch cases with guards compiled incorrectly

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Sep 1 11:09:41 UTC 2023


On Fri, 1 Sep 2023 11:04:34 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> I wonder if the real issue is that there is no real `when` guard emitted for the second `case` (because of javac getting confused with cascading).

To be clear, IMHO the generated code should be:


switch (java.lang.runtime.SwitchBootstraps.typeSwitch(selector0$temp, index$1)) {
case 0:
    Integer _;
    if (!(true && ((Integer)obj) > 0)) {
        index$1 = 1;
        continue;
    }
    return 1;

case 1:
    String _;
    if (!(true && !((String)obj).isEmpty())) {
        index$1 = 2;
        continue;
    }
    return 1;
}

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

PR Comment: https://git.openjdk.org/jdk/pull/15532#issuecomment-1702575831


More information about the compiler-dev mailing list