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

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Sep 5 16:52:12 UTC 2024


On Thu, 5 Sep 2024 16:43:21 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:

>> 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.
>
> We want the regular default body to be in the last position.

ok

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

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


More information about the babylon-dev mailing list