On Tue, 17 Mar 2026 11:30:58 GMT, David Beaumont <[email protected]> wrote:

>> javac + execution environment vs. compilation environment should have no 
>> impact on the boot class loader.
>> 
>> Instead I think it's just that the jimage file is being opened/accessing 
>> before arguments are fully parsed. The jimage file may contain an "options" 
>> resource that contributes to the set of arguments so that is one case where 
>> the argument to enable preview features may be in the options file. I need 
>> to study it more to see if there are other cases.
>
> There definitely are no other cases in terms of when jimage is accessed, 
> because if there were, my code would fail (because of the "uninitialized" 
> state check). Assuming nothing can ever reset the enable-preview flag in 
> `Arguments` (which I'm sure is the case) there cannot any reads which could 
> accidentally use the wrong value. And all the direct reads of the jimage are 
> encapsulated.

It's a bit surprising that it's a side effect of ClassLoader::lookup_vm_options 
that opens the jimage file but it's okay, and not changed here. It's also a bit 
surprising that ClassLoader knows about the jdk/internal/vm/options resource, I 
would have through that  Arguments::parse would be a better place to 
encapsulate that name (but again, you haven't changed this).

Anyway, just to confirm that that it is the lookup of this resource that 
creates scenario where it has to be opened before `--enable-preview` is seen. I 
think what you have with the enum is okay.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29414#discussion_r2976480372

Reply via email to