RFR: 8315130: java.lang.IllegalAccessError when processing classlist to create CDS archive [v8]
Calvin Cheung
ccheung at openjdk.org
Tue Apr 15 18:03:49 UTC 2025
On Mon, 14 Apr 2025 14:04:33 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 one additional commit since the last revision:
>
> Remove unused imports
I have one comment in CDS.java.
src/java.base/share/classes/jdk/internal/misc/CDS.java line 390:
> 388: @Override
> 389: public byte[] readClassFile(String className) throws IOException {
> 390: final var subPath = className.replace('.', File.separatorChar).concat(".class");
Should File.separatorChar be ‘/‘ ? (just like at line 369)
-------------
PR Review: https://git.openjdk.org/jdk/pull/24223#pullrequestreview-2769319159
PR Review Comment: https://git.openjdk.org/jdk/pull/24223#discussion_r2045182045
More information about the core-libs-dev
mailing list