On Wed, 25 Nov 2026 22:38:11 GMT, Jiangli Zhou <[email protected]> wrote:
> Please review a fix in heap dumper that emits a synthetic <classes> instance > field in java.lang.ClassLoader (and subclasses). > > [JDK-8391308](https://bugs.openjdk.org/browse/JDK-8391308) removed > ClassLoader.classes. All non-bootstrap class loaders (PlatformClassLoader, > AppClassLoader and custom ClassLoaders) are affected whenever a loaded Class > has no live instances (or subclass instances) on the heap. This can cause > undetected leaks because objects referenced only by static fields have no GC > root path in the heap dump. > > This PR adds a synthetic <classes> field descriptor to j.l.ClassLoader. The > dumped ClassLoader.<classes> instance field references a synthetic > HPROF_GC_OBJ_ARRAY_DUMP, which holds the mirrors of the loaded, non-hidden > classes. The synthetic array IDs are generated by the FlatObjectDumper. > No Java heap array objects are created for dumping the synthetic <classes>. > This avoids potential allocation failures if Java heap is full, which may be > the reason the heap dump was triggered. > > Fixing heap dumper avoids requiring changes to existing HPROF parser tools. > > With the fix, the new ClassStaticFieldReachabilityTest.java passes. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai). I've posted a couple of questions. I've not completed my review yet. src/hotspot/share/services/heapDumper.cpp line 1000: > 998: } > 999: > 1000: // FIXME: Handle ClassLoader <classes> Q: Can this `FIXME` be removed now? Does it describe already implemented functionality? Otherwise, should it be more specific what exactly is missed? test/hotspot/jtreg/serviceability/HeapDump/ClassStaticFieldReachabilityTest.java line 43: > 41: /* > 42: * @test > 43: * @bug 8391308 Q: Should the @bug include the `8398305` as well? test/hotspot/jtreg/serviceability/HeapDump/ClassStaticFieldReachabilityTest.java line 99: > 97: assertTrue(fooClass.getInstancesCount(false) == 0, > 98: "Foo class instance count should be 0"); > 99: } Q: The lines 93-98 check reachability. Should the test check for existence of the synthetic reference? Could it check that the `<classes>` edges are not missing? ------------- PR Review: https://git.openjdk.org/jdk/pull/34078#pullrequestreview-6126066844 PR Review Comment: https://git.openjdk.org/jdk/pull/34078#discussion_r4750062781 PR Review Comment: https://git.openjdk.org/jdk/pull/34078#discussion_r4750039145 PR Review Comment: https://git.openjdk.org/jdk/pull/34078#discussion_r4750114737
