On Fri, 13 Mar 2026 14:10:06 GMT, Alan Bateman <[email protected]> wrote:
>> Ahh, I've remembered. It *used* to be true that you only needed to test the >> flag, but the changes in the 2nd PR (adding exploded image support) mean >> that the flag is now also used for that too, and needs to be usable when no >> jimage is opened, but this function is purely about whether the both the >> jimage and the flag are present and usable. >> >> This is why I changed the flag status names from "JIMAGE_XXX" to >> "PREVIEW_MODE_XXX" because the flag isn't limited to jimage use now, but the >> function stays as "jimage_is_initialized" not "preview_mode_is_initialized". >> >> See: >> https://github.com/openjdk/valhalla/commit/423e6934ad7e50f8c13ec2a79a2f6adf36584856 >> for where the semantics changed (slightly). > > Are you are sure that ClassPathImageEntry::open_stream_for_loader can't use > Arguments::enable_preview to test if preview features are enabled? The > command line has --enable-preview or it doesn't, so I think I'm missing the > sequencing that requires PREVIEW_MODE_UNINITIALIZED. Preview mode is not only controlled by --enable-preview because Javac needs to have different values from its runtime during compilation. PREVIEW_MODE_UNINITIALIZED is more of an internal guard to prevent a future change from reading the jimage file "too early" and getting the non-preview version of something by accident. Some options are read from the jimage itself, and are read without reference to "preview mode", and they must be processed before anyone starts reading anything else. The "raw" read of the options from the jimage file is the only read allowed while PREVIEW_MODE_UNINITIALIZED is set, and any "normal" reads must be done after initialisation is complete. See `lookup_vm_options()` for where the "raw" read is performed *before* preview mode can be set. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/29414#discussion_r2939918044
