1 /*
2 * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 /*
26 * @test
27 * @summary Tests how CDS works when critical library classes are replaced with JVMTI ClassFileLoadHook
28 * @library /test/lib
29 * @requires vm.cds.write.archived.java.heap
30 * @requires !vm.jvmci.enabled
31 * @build jdk.test.whitebox.WhiteBox
32 * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar whitebox.jar jdk.test.whitebox.WhiteBox
33 * @run main/othervm/native ReplaceCriticalClassesForSubgraphs
34 */
35
36 public class ReplaceCriticalClassesForSubgraphs extends ReplaceCriticalClasses {
37 public static void main(String args[]) throws Throwable {
38 ReplaceCriticalClassesForSubgraphs rcc = new ReplaceCriticalClassesForSubgraphs();
39 rcc.process(args);
40 }
41
42 public String[] getTests() {
43 String tests[] = {
44 // Try to replace classes that are used by the archived subgraph graphs. (CDS should be disabled)
45 "-early -notshared -subgraph java/lang/module/ResolvedModule jdk.internal.module.ArchivedModuleGraph",
46 "-early -notshared -subgraph java/lang/Integer java.lang.Integer$IntegerCache",
47
48 // CDS should not be disabled -- these critical classes cannot be replaced because
49 // JvmtiExport::early_class_hook_env() is false.
50 "-subgraph java/lang/module/Configuration java.lang.module.Configuration",
51 "-subgraph java/lang/ModuleLayer java.lang.ModuleLayer",
52 "-subgraph java/lang/Integer java.lang.Integer$IntegerCache",
53
54 // Tests for archived full module graph. We cannot use whitebox, which requires appending to bootclasspath.
55 // VM will disable full module graph if bootclasspath is appended.
56 "-nowhitebox -early -notshared -subgraph java/lang/Module jdk.internal.module.ArchivedBootLayer",
57 "-nowhitebox -early -notshared -subgraph java/lang/ModuleLayer jdk.internal.module.ArchivedBootLayer",
58 "-nowhitebox -subgraph java/lang/Module jdk.internal.module.ArchivedBootLayer",
59 "-nowhitebox -subgraph java/lang/ModuleLayer jdk.internal.module.ArchivedBootLayer",
60 };
61 return tests;
62 }
63 }