RFR: 8328313: Archived module graph should allow identical --module-path to be specified during dump time and run time [v5]

Calvin Cheung ccheung at openjdk.org
Fri Sep 27 17:36:45 UTC 2024


On Fri, 27 Sep 2024 11:11:20 GMT, Alan Bateman <alanb at openjdk.org> wrote:

> Do you remember why resetArchivedStates resets the resource cache? I would expected it to be cleared for all class loaders.
> 

I think it is because `resourceCache` is a `SoftReference` and it will fail the check in `JavaClasses::is_supported_for_archiving()`.

> Rather than putting something specific to the app class loader here then maybe it should be renamed and have resetArchivedStates call it, e.g.
> 
> ```
>     void resetArchivedStates(boolean all) {
>         ucp = null;
>         resourceCache = null;
>         if (all) {
>             moduleToReader.clear();
>         }
>     }
> ```

Under `if(all)`, we also need to do `setClassPath(null)`.
If I understand your suggestion correctly, in `BuiltinClassLoader`:

    private void resetArchivedStates() {
        resetArchivedStates(false);
    }


In `ClassLoaders.AppClassLoader`:

        private void resetArchivedStates() {
            resetArchivedStates(true);
        }

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21048#discussion_r1778944555


More information about the core-libs-dev mailing list