On Mon, 29 Sep 2025 01:50:01 GMT, Roger Riggs <[email protected]> wrote:

>> C++ changes for supporting preview mode when preview mode resources (with 
>> new location flags) are available.
>> 
>> At the moment, this code will operate on non-preview jimage files (1.0) and 
>> act as if no preview resources are available by virtue of the default value 
>> for missing attributes being zero (which matches location flags for "normal" 
>> entries).
>
> src/java.base/share/native/libjimage/imageFile.hpp line 259:
> 
>> 257:         // it exists in the same module.
>> 258:         FLAGS_IS_PREVIEW_ONLY = 0x4
>> 259:     };
> 
> A refactoring of the flags can avoid conflicting states.
> FLAGS_IS_PREVIEW_VERSION = 2;   // set for preview version
> FLAGS_NO_NORMAL_VERSION = 1;    // preserving the zero value for normal and 
> no preview.
> 
> Create static methods in ImageLocation to perform the desired tests on flags.
> The utility methods make the code easier to read.
> Also define macros/function in the native code in ImageFile and jimage.
> 
> isPreviewVersion(flags) { return (flags & FLAGS_IS_PREVIEW_VERSION) != 0)}
> isPreviewOnly(flags) { return (flags & FLAGS_IS_REVIEW_VERSION | 
> FLAGS_NO_NORMAL_VERSION) == FLAGS_NO_NORMAL_VERSION}

Reprise:

Your name FLAGS_IS_PREVIEW_ONLY probably better than FLAGS_NO_NORMAL_VERSION 
and has the same semantics.

FLAGS_HAS_PREVIEW_VERSION means that there is a preview version and it will be 
found in the <META-INF/Preview> hierarchy. if the flag is in the preview node 
then this is it. If found in the normal hierarchy, the preview class is found 
in the <META-INF/Preview> hierarchy.

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

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/1618#discussion_r2388252261

Reply via email to