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

David Beaumont duke at openjdk.org
Wed Oct 8 11:37:48 UTC 2025


On Mon, 29 Sep 2025 01:41:02 GMT, Roger Riggs <rriggs 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.

ModulesReference are different flags, with different semantics. That's why I made sure they were private and provided helper methods for reading/writing the package directory offsets (because I did trip over using the wrong constants at one point).

I agree it's weird/annoying to have this similar-but-different set of flags, but the ModuleReference flags are completely encapsulated in one place, so cannot be accidentally confused with, or misused in place of the ImageLocation flags.

These flags have a requirement of being zero for almost all entries to reduce image file size, while the ModulesReference flags need to additive for merging (and are not stored in the same part of the jimage file).

I could change flag ordering to make the values match, but since they must never be mistaken for each other, I'm not sure that's beneficial (if anything it might foster the idea that the flags can be used interchangeably in some way).

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

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


More information about the valhalla-dev mailing list