RFR: 8374639: Static archive with AOTClassLinking breaks dynamic archive

Matias Saavedra Silva matsaave at openjdk.org
Wed Jan 7 20:54:03 UTC 2026


On Wed, 7 Jan 2026 06:10:58 GMT, Ioi Lam <iklam at openjdk.org> wrote:

> **Bug fix**
> 
> The assert happens because [JDK-8309240](https://bugs.openjdk.org/browse/JDK-8309240) (Array classes should be stored in dynamic CDS archive) is not compatible with `AOTClassLinking` since JDK 26.
> 
> Since the benefit of [JDK-8309240](https://bugs.openjdk.org/browse/JDK-8309240) is small (obj array classes can be quickly created at run time), we should remove [JDK-8309240](https://bugs.openjdk.org/browse/JDK-8309240).
> 
> **Background**
> 
> The incompatibility is caused by [JDK-8350550](https://bugs.openjdk.org/browse/JDK-8350550) (Preload classes from AOT cache during VM bootstrap) added in JDK 26.
> 
> [JDK-8309240](https://bugs.openjdk.org/browse/JDK-8309240) adds support for scenarios like this:
> 
> - class `Foo` is in the static archive, but `Foo[]` is not in the static archive
> - class `Foo[]` is in the dynamic archive
> 
> There's a pointer from the InstanceKlass of `Foo` to its array class `Foo[]` (`InstanceKlass::_array_klasses`). With [JDK-8309240](https://bugs.openjdk.org/browse/JDK-8309240), we update this pointer to point to `Foo[]` right after the CDS archives are mapped. This happens before `vmClasses::resolve_all()`:
> 
> https://github.com/openjdk/jdk/blob/dd20e9150666f247af61dfa524a170ef7dd96c03/src/hotspot/share/cds/aotMetaspace.cpp#L2162
> 
> With [JDK-8350550](https://bugs.openjdk.org/browse/JDK-8350550), if the static archive has AOT-linked classes, we will restore all of its classes inside `vmClasses::resolve_all()` -- see the callstack in the Description of [JDK-8374639](https://bugs.openjdk.org/browse/JDK-8374639).
> 
> The class restoration requires that all the classes (both instance classes and their array classes) must have a Java mirror. In this example, `Foo` is from the static archive and has an archived Java mirror, so we are OK. However, `Foo[]` is from the dynamic archive and doesn't have an archived mirror. Also, we are too early in the bootstrap process so we are unable to allocate a Java mirror from the heap yet. Hence the assert.

This change looks good! It will also help in lworld considering we ran into similar problems with the array metadata refactor. Thanks!

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

Marked as reviewed by matsaave (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/29078#pullrequestreview-3636748558


More information about the hotspot-runtime-dev mailing list