On Sun, 29 Sep 2024 04:23:14 GMT, Ioi Lam <ik...@openjdk.org> wrote: >> Added braces. >> The `setClassPath(null)` used to be in `ClassLoaders.AppClassLoader`. Based >> on investigations so far, the clearing of the `moduleToReader` map is >> required only for `AppClassLoader`. > > Why does it need to clear `moduleToReader` only for app loader and not for > platform loader? Is it because the `moduleToReader` for the app loader may > contain reference to jar files that indirectly references some file system > objects? > > Since moduleToReader is just a cache, I think it's better to always clear it > for both loaders. Also, the logic can be moved into BuiltinClassLoader: > > > class BuiltinClassLoader { > .... > private void resetArchivedStates() { > ucp = null; > resourceCache = null; > setClassPath(null); // AppClassLoader will initialize this again > at runtime. > moduleToReader.clear(); > }
setClassPath(null) is the same as `ucp = null` but yes, keep it simple as otherwise there will be question each time there are changes. BuiltinClassPath should not include any code that is specific to the app class loader or the platform class loader as there are specific subclasses for that. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21048#discussion_r1779923680