1 /* 2 * Copyright (c) 2018, 2020, 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.archived.java.heap 30 * @build sun.hotspot.WhiteBox 31 * @run driver ClassFileInstaller -jar whitebox.jar sun.hotspot.WhiteBox 32 * @run main/othervm/native ReplaceCriticalClassesForSubgraphs 33 */ 34 35 public class ReplaceCriticalClassesForSubgraphs extends ReplaceCriticalClasses { 36 public static void main(String args[]) throws Throwable { 37 ReplaceCriticalClassesForSubgraphs rcc = new ReplaceCriticalClassesForSubgraphs(); 38 rcc.process(args); 39 } 40 41 public String[] getTests() { 42 String tests[] = { 43 // Try to replace classes that are used by the archived subgraph graphs. (CDS should be disabled) 44 "-early -notshared -subgraph java/lang/module/ResolvedModule jdk.internal.module.ArchivedModuleGraph", 45 "-early -notshared -subgraph java/lang/Long java.lang.Long$LongCache", 46 47 // CDS should not be disabled -- these critical classes cannot be replaced because 48 // JvmtiExport::early_class_hook_env() is false. 49 "-subgraph java/lang/module/ResolvedModule jdk.internal.module.ArchivedModuleGraph", 50 "-subgraph java/lang/Long java.lang.Long$LongCache", 51 52 // Tests for archived full module graph. We cannot use whitebox, which requires appending to bootclasspath. 53 // VM will disable full module graph if bootclasspath is appended. 54 "-nowhitebox -early -notshared -subgraph java/lang/Module jdk.internal.module.ArchivedBootLayer", 55 "-nowhitebox -early -notshared -subgraph java/lang/ModuleLayer jdk.internal.module.ArchivedBootLayer", 56 "-nowhitebox -subgraph java/lang/Module jdk.internal.module.ArchivedBootLayer", 57 "-nowhitebox -subgraph java/lang/ModuleLayer jdk.internal.module.ArchivedBootLayer", 58 }; 59 return tests; 60 } 61 }