RFR: 8319220: Pattern matching switch with a lot of cases is unduly slow [v2]

Jan Lahoda jlahoda at openjdk.org
Fri Nov 3 16:30:08 UTC 2023


On Fri, 3 Nov 2023 15:24:48 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 346:
>> 
>>> 344:                     Class<?> clazz = label.constantType().resolveConstantDesc(lookup);
>>> 345: 
>>> 346:                     if (value.getClass() != clazz) {
>> 
>> Not related to this patch, but this appears to be wrong: we should do something like
>> 
>> if (!(value instanceof Enum<?> ev) || ev.getDeclaringClass() != clazz)
>>     return SENTINEL; // or false
>
> You are right, of course, but let's solve that under [JDK-8318144](https://bugs.openjdk.org/browse/JDK-8318144), to ensure that can more easily be backported. Tests are running on the fix, will publish PR once they pass. Thanks!

FYI:
https://github.com/openjdk/jdk/pull/16499

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16489#discussion_r1381950105


More information about the core-libs-dev mailing list