On Wed, 16 Apr 2025 21:52:46 GMT, Ioi Lam <ik...@openjdk.org> wrote: >> 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)); > }
Overshadowing should be checked before attempting to load the class. Otherwise if the wrongly used super has a different classfile than the specified super we may get class loading errors (see JVMS 5.3.5.3 and 5.3.5.4), e.g. if the specified super wasn't final but we try to use a final class instead of it. I'll extend the related explanation comments in the code. > Does this always prevent an unregistered class to use any other unregistered > class as its super type? The only way I see for another class to be used instead is for the unregistered class being loaded to reference supertypes of unexpected names in its classfile. But this is an error and it will be detected as such in the C++ code you've cited. If you have any other cases in mind please share. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/24223#discussion_r2048379190