RFR: 8303374: Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) [v41]

Jan Lahoda jlahoda at openjdk.org
Wed Jan 24 10:29:35 UTC 2024


On Wed, 24 Jan 2024 03:47:06 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> Aggelos Biboudis has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 60 commits:
>> 
>>  - Improve Javadoc of ExactConversionsSupport
>>  - Merge branch 'master' into primitive-patterns
>>  - Update ExactConversionsSupport Javadoc and JDK version
>>  - Revert "Update copyright year, javadoc, JDK version"
>>    
>>    This reverts commit 676af9de90d946f64f34762a6df94dbd91bce41b.
>>  - Update copyright year, javadoc, JDK version
>>  - Merge branch 'master' into primitive-patterns
>>  - Merge branch 'master' into primitive-patterns
>>  - Cleanup
>>  - Merge branch 'master' into primitive-patterns
>>  - Remove trailing spaces
>>  - ... and 50 more: https://git.openjdk.org/jdk/compare/c9cacfb2...50cb9832
>
> src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 72:
> 
>> 70:     private static final Object SENTINEL = new Object();
>> 71:     private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
>> 72:     private static final boolean previewEnabled = true;
> 
> not sure about the use of this constant, do we really need it?

Uh, I think this is a good catch.

I am not completely sure what the policy is, but here we are enhancing a non-preview method with some preview-based behavior. I would feel better if the method would refuse to work in the preview way when preview is not enabled. I.e. my opinion is that this should either be initialized to `jdk.internal.misc.PreviewFeatures.isEnabled()`, or `jdk.internal.misc.PreviewFeatures.ensureEnabled()` should be used appropriately.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1464693259


More information about the core-libs-dev mailing list