On Fri, 27 Mar 2026 18:50:49 GMT, Ioi Lam <[email protected]> wrote:

>> Paul Hübner has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   Move autobox check to ciField.
>
> src/java.base/share/classes/java/lang/Byte.java line 151:
> 
>> 149: 
>> 150:         static boolean isEnabled() {
>> 151:             return cache != unused;
> 
> Overall it looks good to me, but is it possible to do this:
> 
> 
>  static boolean isEnabled() {
>      return cache != null;
> 
> 
> That way you don't need the `unused` anymore.

Will this `@stable` constant fold the value? I thought the `@stable` assumes 
only values except for `null` or `0` are stable. So if the `cache` is always 
`null`, it is also always unstable and not constant folded. Maybe this has 
changed, or our compiler is allowed to trust some special final fields to be 
final now.

If we can trust the internal final field to be constant folded we should be 
able to just use `!PreviewFeatures.isEnabled()`. The reason for the unused 
sentinel was to ensure that it got `@stable` constant folded.

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

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2249#discussion_r3009784200

Reply via email to