On Tue, 25 Nov 2025 15:57:56 GMT, David Beaumont <[email protected]> wrote:

>> Plumbing for javac flags, mostly inspired by/copied from test commits made 
>> by @lahodaj .
>> 
>> There are several things here, mostly entangled, so it's a bit tricky to try 
>> splitting this out, but it would be possible if people wanted.
>> 
>> The biggest "refactoing" part of this PR is 
>> "src/jdk.compiler/share/classes/com/sun/tools/javac/file/JRTIndex.java" 
>> which now has a properly controlled lifecycle and disposed its resources 
>> correctly. Prior to this, the class used a non-closeable JRT file-system 
>> reference, which leads to "persistent open file" issues such as JDK-8357249.
>> 
>> This *does* mean that if compilation and the runtime have the same preview 
>> mode, then a 2nd JRT file system to the same jimage file is "opened", *but* 
>> the file system itself is lightweight, non-caching and both of them will use 
>> the underlying SharedImageReader (which is where nodes are cached etc.) so 
>> it really shouldn't be an issue (I will make sure javac benchmarks are 
>> checked however).
>> 
>> The benefit of this is that now, the shared index (which does do some 
>> caching) is correctly tracked across all users, and will be closed when the 
>> last user closes the lightweight wrapper instance.
>> 
>> A lot of the smaller "spot fix" changes in this PR were just copied by me, 
>> or at least inspired directly by Jan's work, so I may have missed some 
>> semantic subtlety in the code I'm not familiar with. Please evaluate that 
>> carefully.
>
> David Beaumont has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Remove note about StableValue (not possible)

src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java line 
1587:

> 1585:                 }  else if (proxy.type.tsym == syms.valueBasedType.tsym 
> && sym.kind == TYP) {
> 1586:                     sym.flags_field |= VALUE_BASED;
> 1587:                 }  else if (!DISABLE_PREVIEW_PATCHING

Currently, the migrated value classes are marked with 
`@jdk.internal.MigratedValueClass` (or the corresponding javac-internal 
annotation). And this code will mark such classes as value-based, even if the 
original classfile is not the preview classfile. This has a similar real-world 
effect as reading the appropriate preview class, but this annotation is AFAIK 
only temporary. So if the new approach is enabled, we disable the special 
handling of the annotation, and rely on reading the appropriate preview class. 
This is to see the eventual effect of enabling the support for preview classes 
inside JRT FS, and abandoning migrated value class.

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

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/1761#discussion_r2606081171

Reply via email to