RFR: 8337548: Parallel class loading can pass pass is_superclass true for interfaces

Coleen Phillimore coleenp at openjdk.org
Mon Jan 27 23:09:27 UTC 2025


There's an optimization in class loading that looks up class being loaded while loading its superclass, and if the class is found, it will check the superclass name against klass->_super and match class loaders. It's supposed to be a optimization to short circuit taking out the LOAD_SUPER (now called DETECT_CIRCULARITY) placeholder for the class being loaded.  So for example, loading class C, super S, we take out a DETECT_CIRCULARITY placeholder for C to detect if S then tries to load C as a super class by the same thread.

This optimization is almost never done because it requires just the right timing for a parallel thread to load the class right before this thread reaches the if statement (perhaps some long stall). The only case where this code is reached normally is for redefinition.  Loading a new class file version will find the class in the System Dictionary because we can only redefine already loaded classes.

It should be harmess to remove this if-statement in the case of redefinition also, but I think having a placeholder created for a known already-loaded class seems to break an understanding of how this works.  So I opted to just add to the comment and restructure the method a little bit.  The dictionary->find_class() call doesn't need to be inside the SystemDictionary_lock.

Tested with tier1-4 and internal parallel class loading tests.

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

Commit messages:
 - 8337548: Parallel class loading can pass pass is_superclass true for interfaces

Changes: https://git.openjdk.org/jdk/pull/23322/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=23322&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8337548
  Stats: 40 lines in 2 files changed: 9 ins; 8 del; 23 mod
  Patch: https://git.openjdk.org/jdk/pull/23322.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/23322/head:pull/23322

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


More information about the hotspot-runtime-dev mailing list