On Wed, 24 Jan 2024 10:26:18 GMT, Jan Lahoda <jlah...@openjdk.org> wrote:
>> 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. Used the `jdk.internal.misc.PreviewFeatures.isEnabled()` and remove an erroneous check in `typeSwitch`. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1464801847