RFR: 8315130: java.lang.IllegalAccessError when processing classlist to create CDS archive [v10]
Ioi Lam
iklam at openjdk.org
Wed Apr 16 21:57:46 UTC 2025
On Wed, 16 Apr 2025 14:34:25 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 with a new target base due to a merge or a rebase. The pull request now contains 15 commits:
>
> - Empty commit to make GH update the PR
> - Merge remote-tracking branch 'openjdk-jdk/master' into one-loader
> - Implement super overshadowing warning
> - Omit Source classes from archive
> - Remove unused imports
> - Fix indentation
> - Extend ClassFromClasspath test
> - Remove findClass, extend explanation comments
> - Remove unnecessary scoping
> - Don't use URLClassPath
> - ... and 5 more: https://git.openjdk.org/jdk/compare/465c8e65...595756f3
src/hotspot/share/cds/classListParser.cpp line 517:
> 515: return;
> 516: }
> 517: assert(!supertype->is_shared_unregistered_class(), "unregistered supertype cannot be overshadowed");
Does this always prevent an unregistered class to use any other unregistered class as its super type?
I think a better check would be here:
if (!k->local_interfaces()->contains(specified_interface)) {
+ jio_fprintf(defaultStream::error_stream(), "Specified interface %s (id %d) is not directly implemented\n",
+ specified_interface->external_name(), _interfaces->at(i));
print_specified_interfaces();
print_actual_interfaces(k);
+ throw exception .....
- error("Specified interface %s (id %d) is not directly implemented",
- specified_interface->external_name(), _interfaces->at(i));
}
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24223#discussion_r2047820496
More information about the hotspot-runtime-dev
mailing list