> 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.
> 
> Implementation note: `URLClassLoader` does not allow selecting a specific URL 
> to load a specific class — I used reflection to override a private part of 
> `URLClassLoader` responsible for URL selection while being able to use the 
> rest of its implementation.

Timofei Pushkin has updated the pull request incrementally with one additional 
commit since the last revision:

  Test classpath case

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/24223/files
  - new: https://git.openjdk.org/jdk/pull/24223/files/3be4c5f9..784c1a83

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=24223&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=24223&range=00-01

  Stats: 53 lines in 1 file changed: 53 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/24223.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24223/head:pull/24223

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

Reply via email to