< prev index next > test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java
Print this page
/*
! * Copyright (c) 2018, 2024, 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.
/*
! * Copyright (c) 2018, 2026, 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.
* @test
* @summary Tests how CDS works when critical library classes are replaced with JVMTI ClassFileLoadHook
* @library /test/lib
* @requires vm.cds.write.archived.java.heap
* @requires !vm.jvmci.enabled
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller -jar whitebox.jar jdk.test.whitebox.WhiteBox
* @run main/othervm/native ReplaceCriticalClassesForSubgraphs
*/
public class ReplaceCriticalClassesForSubgraphs extends ReplaceCriticalClasses {
public static void main(String args[]) throws Throwable {
ReplaceCriticalClassesForSubgraphs rcc = new ReplaceCriticalClassesForSubgraphs();
rcc.process(args);
}
public String[] getTests() {
! String tests[] = {
// Try to replace classes that are used by the archived subgraph graphs. (CDS should be disabled)
"-early -notshared -subgraph java/lang/module/ResolvedModule jdk.internal.module.ArchivedModuleGraph",
"-early -notshared -subgraph java/lang/Integer java.lang.Integer$IntegerCache",
// CDS should not be disabled -- these critical classes cannot be replaced because
// JvmtiExport::early_class_hook_env() is false.
"-subgraph java/lang/module/Configuration java.lang.module.Configuration",
"-subgraph java/lang/ModuleLayer java.lang.ModuleLayer",
- "-subgraph java/lang/Integer java.lang.Integer$IntegerCache",
// Tests for archived full module graph. We cannot use whitebox, which requires appending to bootclasspath.
// VM will disable full module graph if bootclasspath is appended.
"-nowhitebox -early -notshared -subgraph java/lang/Module jdk.internal.module.ArchivedBootLayer",
"-nowhitebox -early -notshared -subgraph java/lang/ModuleLayer jdk.internal.module.ArchivedBootLayer",
"-nowhitebox -subgraph java/lang/Module jdk.internal.module.ArchivedBootLayer",
! "-nowhitebox -subgraph java/lang/ModuleLayer jdk.internal.module.ArchivedBootLayer",
! };
! return tests;
}
}
* @test
* @summary Tests how CDS works when critical library classes are replaced with JVMTI ClassFileLoadHook
* @library /test/lib
* @requires vm.cds.write.archived.java.heap
* @requires !vm.jvmci.enabled
+ * @modules java.base/jdk.internal.misc
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller -jar whitebox.jar jdk.test.whitebox.WhiteBox
* @run main/othervm/native ReplaceCriticalClassesForSubgraphs
*/
+ import java.util.ArrayList;
+ import java.util.Arrays;
+ import jdk.internal.misc.PreviewFeatures;
+
public class ReplaceCriticalClassesForSubgraphs extends ReplaceCriticalClasses {
public static void main(String args[]) throws Throwable {
ReplaceCriticalClassesForSubgraphs rcc = new ReplaceCriticalClassesForSubgraphs();
rcc.process(args);
}
public String[] getTests() {
! ArrayList<String> tests = new ArrayList<String>(Arrays.asList(
// Try to replace classes that are used by the archived subgraph graphs. (CDS should be disabled)
"-early -notshared -subgraph java/lang/module/ResolvedModule jdk.internal.module.ArchivedModuleGraph",
"-early -notshared -subgraph java/lang/Integer java.lang.Integer$IntegerCache",
// CDS should not be disabled -- these critical classes cannot be replaced because
// JvmtiExport::early_class_hook_env() is false.
"-subgraph java/lang/module/Configuration java.lang.module.Configuration",
"-subgraph java/lang/ModuleLayer java.lang.ModuleLayer",
// Tests for archived full module graph. We cannot use whitebox, which requires appending to bootclasspath.
// VM will disable full module graph if bootclasspath is appended.
"-nowhitebox -early -notshared -subgraph java/lang/Module jdk.internal.module.ArchivedBootLayer",
"-nowhitebox -early -notshared -subgraph java/lang/ModuleLayer jdk.internal.module.ArchivedBootLayer",
"-nowhitebox -subgraph java/lang/Module jdk.internal.module.ArchivedBootLayer",
! "-nowhitebox -subgraph java/lang/ModuleLayer jdk.internal.module.ArchivedBootLayer"));
!
! // IntegerCache does not exist in preview mode so it should not be expected in the output
+ if (!PreviewFeatures.isEnabled()) {
+ // CDS should not be disabled -- these critical classes cannot be replaced because
+ // JvmtiExport::early_class_hook_env() is false.
+ tests.add("-subgraph java/lang/Integer java.lang.Integer$IntegerCache");
+ }
+
+ return tests.toArray(new String[0]);
}
}
< prev index next >