[lworld] RFR: 8366093: [lworld] Add preview mode to C++ classloader

Roger Riggs rriggs at openjdk.org
Mon Sep 29 01:52:48 UTC 2025


On Tue, 23 Sep 2025 19:11:41 GMT, David Beaumont <duke at openjdk.org> 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 253:

> 251:         // Set on a "normal" (non-preview) location if a preview version of
> 252:         // it exists in the same module.
> 253:         FLAGS_HAS_PREVIEW_VERSION = 0x1,

To avoid confusion, the value and spelling of the flag should agree across all modules.
In ImageLocation and jimage/ModulesReference.

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}

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

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


More information about the valhalla-dev mailing list