RFR: 8373436: Cleanup JRTIndex usages [v2]
Jan Lahoda
jlahoda at openjdk.org
Thu Dec 11 10:35:31 UTC 2025
> 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.
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/28761/files
- new: https://git.openjdk.org/jdk/pull/28761/files/b9aa5bf4..dc275831
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=28761&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=28761&range=00-01
Stats: 20 lines in 3 files changed: 2 ins; 11 del; 7 mod
Patch: https://git.openjdk.org/jdk/pull/28761.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/28761/head:pull/28761
PR: https://git.openjdk.org/jdk/pull/28761
More information about the compiler-dev
mailing list