Integrated: 8374639: Static archive with AOTClassLinking breaks dynamic archive
Ioi Lam
iklam at openjdk.org
Thu Jan 8 18:44:51 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 pull request has now been integrated.
Changeset: 9fd86e37
Author: Ioi Lam <iklam at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/9fd86e37492c419fbae0837f69aab26a201c927e
Stats: 486 lines in 10 files changed: 95 ins; 380 del; 11 mod
8374639: Static archive with AOTClassLinking breaks dynamic archive
Reviewed-by: coleenp, matsaave
-------------
PR: https://git.openjdk.org/jdk/pull/29078
More information about the hotspot-runtime-dev
mailing list