[code-reflection] RFR: 8337158: Modeling and lowering of switch statement [v13]

Mourad Abbay mabbay at openjdk.org
Fri Aug 16 14:58:58 UTC 2024


On Fri, 16 Aug 2024 13:51:22 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Mourad Abbay has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - Add a test case of switch statement model
>>  - Runtime tests of switch statement
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ReflectMethods.java line 1686:
> 
>> 1684:                 JCTree.JCCaseLabel headCl = c.labels.head;
>> 1685:                 if (headCl instanceof JCTree.JCPatternCaseLabel pcl) {
>> 1686:                     if (c.labels.size() > 1) {
> 
> Can this happen, with patterns?

Yes. Here is an example:

private static String casePatternMultiLabel(Object o) {
        String r = "";
        switch (o) {
            case Integer _, Long _, Character _, Byte _, Short _-> r += "integral type";
            default -> r += "non integral type";
        }
        return r;
    }

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

PR Review Comment: https://git.openjdk.org/babylon/pull/211#discussion_r1719961581


More information about the babylon-dev mailing list