RFR: 8373436: Cleanup JRTIndex usages [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Dec 11 14:32:58 UTC 2025


On Thu, 11 Dec 2025 10:35:31 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

>> The `com.sun.tools.javac.file.JRTIndex` class serves two purposes: a) the keeps a package-oriented cache of directories and files inside the JRT FileSystem; b) allows to get the additional flags for classes in packages on the default classpath. Sadly, it is not easy to completely disentangle these two purposes, as the directories cache also holds the additional flags.
>> 
>> The `JRTIndex` is used on two places, the `ClassFinder`, and in `JavacFileManager`, but the former is only using the additional flags, and the latter is using the cache/index. The logic determining whether the `JRTIndex` is used in `ClassFinder` is also not trivial.
>> 
>> The goal of this PR is to attempt to clean this a bit:
>> - there's a separate abstraction for getting the additional flags (`LegacyCtPropertiesAccess`), with the non-trivial implementation residing in `JavacFileManager`. This allows to concentrate the complex almost completely  inside the file manager.
>> - the `JRTIndex` itself is now a package-private class inside the `....file` package.
>> 
>> It is not a goal of this PR to change the behavior, just make the implementation more understandable.
>> 
>> Note this removal from `ClassFinder`:
>> 
>> -        if (fm instanceof DelegatingJavaFileManager delegatingJavaFileManager) {
>> -            fm = delegatingJavaFileManager.getBaseFileManager();
>> -        }
>> 
>> 
>> The `DelegatingJavaFileManager` is used when `--release` is specified, so this allows to get the underlying base file manager. But, regardless of the underlying base manager, the system classes should always come from the `--release` data, which are not in the underlying base manager, and hence (ultimately), the `JRTIndex` data should not be used by `ClassFinder` when `--release` is used. The removal makes this more obvious.
>
> Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Cleanup: JRTIndex implements LegacyCtPropertiesAccess directly, as suggested.

Looks good!

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

Marked as reviewed by mcimadamore (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/28761#pullrequestreview-3567723858


More information about the compiler-dev mailing list