RFR: 8315130: java.lang.IllegalAccessError when processing classlist to create CDS archive [v7]
Timofei Pushkin
tpushkin at openjdk.org
Mon Apr 14 14:00:40 UTC 2025
> 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:
- Fix indentation
- Extend ClassFromClasspath test
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/24223/files
- new: https://git.openjdk.org/jdk/pull/24223/files/903f0f97..d2e51dac
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=24223&range=06
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=24223&range=05-06
Stats: 75 lines in 3 files changed: 62 ins; 0 del; 13 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
More information about the core-libs-dev
mailing list