RFR: 8348240: Remove SystemDictionaryShared::lookup_super_for_unregistered_class() [v2]

Ioi Lam iklam at openjdk.org
Thu Jan 23 02:04:33 UTC 2025


> I reimplemented `SystemDictionaryShared::lookup_super_for_unregistered_class()` with Java code. This removes hacks in `SystemDictionary::resolve_with_circularity_detection()` to facilitate future clean-ups there that are planned by @coleenp. Please see the [JBS issue](https://bugs.openjdk.org/browse/JDK-8348240) for a discussion of why the hack was there.
> 
> The new Java code is in the `jdk/internal/misc/CDS$UnregisteredClassLoader` class. I also simplified `UnregisteredClasses::create_classloader()` by moving some unwieldy C++ `JavaCalls` code into Java.
> 
> ### How this works:
> 
> For example, let's assume you have the following classfiles in foo.jar:
> 
> 
> interface MyInterface1 {}
> interface MyInterface2 {}
> class MyClass extends Object implements MyInterface1, MyInterface2 {}
> 
> 
> The CDS classlist file can look like this:
> 
> 
> java/lang/Object id: 1
> MyInterface1: id: 2 super: 1 source: foo.jar
> MyInterface2: id: 3 super: 1 source: foo.jar
> MyClass: id: 4 super: 1 interfaces: 2 3 source: foo.jar
> 
> 
> When CDS handles the `MyClass: id: 4` line, it calls `CDS$UnregisteredClassLoader::load()` with the following parameters:
> 
> - `name` = "MyClass"
> - `superClass` = java.lang.Object
> - `interfaces` = {MyInterface1, MyInterface2} 
> 
> `CDS$UnregisteredClassLoader::load()` will start parsing MyClass.class from foo.jar. The ClassFileParser will see symbolic references to the supertypes of `MyClass`. These supertypes will be resolved by `CDS$UnregisteredClassLoader::findClass()`, using the classes provided by `superClass` and `interfaces`.

Ioi Lam has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:

 - Merge branch 'master' into 8348240-remove-lookup_super_for_unregistered_class
 - @calvinccheung comments
 - 8348240: Remove SystemDictionaryShared::lookup_super_for_unregistered_class()

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/23226/files
  - new: https://git.openjdk.org/jdk/pull/23226/files/ca801052..e03dfc50

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

  Stats: 1256 lines in 46 files changed: 574 ins; 462 del; 220 mod
  Patch: https://git.openjdk.org/jdk/pull/23226.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/23226/head:pull/23226

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


More information about the core-libs-dev mailing list