On Tue, 25 Mar 2025 11:08:24 GMT, Timofei Pushkin <tpush...@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.

This pull request has now been integrated.

Changeset: 46a12e78
Author:    Timofei Pushkin <tpush...@openjdk.org>
Committer: Ioi Lam <ik...@openjdk.org>
URL:       
https://git.openjdk.org/jdk/commit/46a12e781edcbe9da7bd39eb9e101fc680053cef
Stats:     671 lines in 13 files changed: 486 ins; 122 del; 63 mod

8315130: java.lang.IllegalAccessError when processing classlist to create CDS 
archive

Reviewed-by: iklam, ccheung

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

PR: https://git.openjdk.org/jdk/pull/24223

Reply via email to