RFR: 8315130: java.lang.IllegalAccessError when processing classlist to create CDS archive [v11]

Ioi Lam iklam at openjdk.org
Thu Apr 17 22:40:46 UTC 2025


On Thu, 17 Apr 2025 07:41:36 GMT, Timofei Pushkin <tpushkin at openjdk.org> wrote:

>> If a base class is package-private then its subclasses should have the same package name and defining class loader, otherwise `IllegalAccessError` is thrown when linking a subclass. Currently when dumping a static archive separate `URLClassLoader`s are used for each unregistered classes' source. Thus if two unregistered classes, a package-private base class and a sub class, from the same package reside in different sources `IllegalAccessError` will be thrown when linking the sub class. This can be unexpected because the app could have used a single class loader for both classes and thus not have seen the error — see `DifferentSourcesApp.java` from this patch for an example of such app.
>> 
>> This patch fixes the issue by using a single class loader for all unregistered classes. CDS does not allow classes with the same name making such solution possible.
>
> Timofei Pushkin has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Make RegUnregSuperTest AOTClassLinking-compatible
>  - Extend overshadowing explanation comments

Looks good to me overall. I just have a request for cleaning up `ClassListParser::check_supertype_overshadowing()`

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

PR Review: https://git.openjdk.org/jdk/pull/24223#pullrequestreview-2777066054


More information about the hotspot-runtime-dev mailing list