[code-reflection] RFR: Unify code that generates code model of switch statement and expression [v3]

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Sep 5 12:37:14 UTC 2024


On Thu, 5 Sep 2024 01:49:24 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:

>> Unify code that generates code model of switch statement and expression
>
> Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Refactor

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ReflectMethods.java line 1533:

> 1531:                 Body.Builder caseBody = visitCaseBody(c, caseBodyType);
> 1532: 
> 1533:                 if (c.labels.head instanceof JCTree.JCDefaultCaseLabel) {

I'm not sure this is optimal - can't we add all labels and bodies (even default ones) and then, after the loop, only add a synthetic default label if `isDefaultCaseNeeded` is set? Or, if there are cases where the flag is set, but there is already a real default label, can we maybe just unset the flag if we see a default label in the loop?

In other words, I don't see what adding the "regular" default body after the loop buys us.

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

PR Review Comment: https://git.openjdk.org/babylon/pull/220#discussion_r1745400613


More information about the babylon-dev mailing list