RFR: 8338979: Avoid bootstrapped switches in the classfile API [v2]

Claes Redestad redestad at openjdk.org
Mon Aug 26 15:39:09 UTC 2024


On Mon, 26 Aug 2024 15:00:29 GMT, Chen Liang <liach at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/classfile/impl/ClassFileImpl.java line 86:
>> 
>>> 84:         var amo = attributeMapperOption;
>>> 85:         for (var o : options) {
>>> 86:             if (o instanceof StackMapsOption oo) {
>> 
>> Just out of curiosity, will this be slower than the switch statement?
>
> It may after `SwitchBootstraps` is improved; but this code will be relied on by `SwitchBootstraps` to generate switches, so it won't be able to use pattern matching switches.

I don't think (throughput) performance matters here, based on patterns in JDK internal code. We use either `ClassFile.of()` which retrieves a pre-initialized singleton (creating which doesn't touch this method) or create a private static final like in `ProxyGenerator`:

    private static final ClassFile CF_CONTEXT =
            ClassFile.of(ClassFile.StackMapsOption.DROP_STACK_MAPS);

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20714#discussion_r1731433796


More information about the core-libs-dev mailing list