From b1a7d3f2e723814788b97a572261db4a63b94334 Mon Sep 17 00:00:00 2001 From: iklam Date: Mon, 31 Mar 2025 23:02:54 -0700 Subject: [PATCH 1/2] 8352775: java -XX:AOTMode=create -XX:+UseZGC crashes --- src/hotspot/share/oops/constantPool.cpp | 2 +- .../aotClassLinking/AOTCacheWithZGC.java | 62 +++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTCacheWithZGC.java diff --git a/src/hotspot/share/oops/constantPool.cpp b/src/hotspot/share/oops/constantPool.cpp index 23e1bc14d38c9..0b6f3543b7a7c 100644 --- a/src/hotspot/share/oops/constantPool.cpp +++ b/src/hotspot/share/oops/constantPool.cpp @@ -455,7 +455,7 @@ void ConstantPool::restore_unshareable_info(TRAPS) { } } - if (CDSConfig::is_dumping_final_static_archive() && resolved_references() != nullptr) { + if (CDSConfig::is_dumping_final_static_archive() && CDSConfig::is_dumping_heap() && resolved_references() != nullptr) { objArrayOop scratch_references = oopFactory::new_objArray(vmClasses::Object_klass(), resolved_references()->length(), CHECK); HeapShared::add_scratch_resolved_references(this, scratch_references); } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTCacheWithZGC.java b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTCacheWithZGC.java new file mode 100644 index 0000000000000..8691aabfef9df --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTCacheWithZGC.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test + * @summary -XX:AOTMode=create should be compatible with ZGC + * @bug 8352775 + * @requires vm.cds + * @requires vm.gc.Z + * @requires vm.gc == null + * @comment work around JDK-8345635 + * @requires !vm.jvmci.enabled + * @library /test/lib + * @build AOTCacheWithZGC + * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar app.jar AOTCacheWithZGCApp + * @run driver AOTCacheWithZGC + */ + +import jdk.test.lib.cds.SimpleCDSAppTester; +import jdk.test.lib.process.OutputAnalyzer; + +public class AOTCacheWithZGC { + public static void main(String... args) throws Exception { + SimpleCDSAppTester.of("AOTCacheWithZGC") + .addVmArgs("-XX:+UseZGC", "-Xlog:cds") + .classpath("app.jar") + .appCommandLine("AOTCacheWithZGCApp") + .setProductionChecker((OutputAnalyzer out) -> { + // AOT-linked classes required cached Java heap objects, which is not + // yet supported by ZGC. + out.shouldContain("Using AOT-linked classes: false"); + }) + .runAOTWorkflow(); + } +} + +class AOTCacheWithZGCApp { + public static void main(String[] args) { + + } +} From 0cdf72ca80c881ac97cce74c3a1ab0560a88f767 Mon Sep 17 00:00:00 2001 From: iklam Date: Tue, 1 Apr 2025 09:23:00 -0700 Subject: [PATCH 2/2] No need to use "@requires vm.gc == null" --- .../runtime/cds/appcds/aotClassLinking/AOTCacheWithZGC.java | 1 - 1 file changed, 1 deletion(-) diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTCacheWithZGC.java b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTCacheWithZGC.java index 8691aabfef9df..5db41236a6761 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTCacheWithZGC.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTCacheWithZGC.java @@ -28,7 +28,6 @@ * @bug 8352775 * @requires vm.cds * @requires vm.gc.Z - * @requires vm.gc == null * @comment work around JDK-8345635 * @requires !vm.jvmci.enabled * @library /test/lib