1 /* 2 * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2024, Red Hat, Inc. All rights reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 */ 24 25 /** 26 * @test id=nocoops_nocoh 27 * @summary Test Loading of default archives in all configurations 28 * @requires vm.cds 29 * @requires vm.bits == 64 30 * @library /test/lib 31 * @modules java.base/jdk.internal.misc 32 * java.management 33 * @run driver TestDefaultArchiveLoading nocoops_nocoh 34 */ 35 36 /** 37 * @test id=nocoops_coh 38 * @summary Test Loading of default archives in all configurations (requires --enable-cds-archive-coh) 39 * @requires vm.cds 40 * @requires vm.bits == 64 41 * @requires !vm.gc.ZGenerational 42 * @library /test/lib 43 * @modules java.base/jdk.internal.misc 44 * java.management 45 * @run driver TestDefaultArchiveLoading nocoops_coh 46 */ 47 48 /** 49 * @test id=coops_nocoh 50 * @summary Test Loading of default archives in all configurations 51 * @requires vm.cds 52 * @requires vm.bits == 64 53 * @library /test/lib 54 * @modules java.base/jdk.internal.misc 55 * java.management 56 * @run driver TestDefaultArchiveLoading coops_nocoh 57 */ 58 59 /** 60 * @test id=coops_coh 61 * @summary Test Loading of default archives in all configurations (requires --enable-cds-archive-coh) 62 * @requires vm.cds 63 * @requires vm.bits == 64 64 * @requires !vm.gc.ZGenerational 65 * @library /test/lib 66 * @modules java.base/jdk.internal.misc 67 * java.management 68 * @run driver TestDefaultArchiveLoading coops_coh 69 */ 70 71 import jdk.test.lib.Platform; 72 import jdk.test.lib.process.OutputAnalyzer; 73 import jdk.test.lib.process.ProcessTools; 74 import jtreg.SkippedException; 75 76 public class TestDefaultArchiveLoading { 77 public static void main(String[] args) throws Exception { 78 79 if (args.length != 1) { 80 throw new RuntimeException("Expected argument"); 81 } 82 83 String archiveSuffix; 84 char coh, coops; 85 86 switch (args[0]) { 87 case "nocoops_nocoh": 88 coh = coops = '-'; 89 archiveSuffix = "_nocoops"; 90 break; 91 case "nocoops_coh": 92 coops = '-'; 93 coh = '+'; 94 archiveSuffix = "_nocoops_coh"; 95 break; 96 case "coops_nocoh": 97 coops = '+'; 98 coh = '-'; 99 archiveSuffix = ""; 100 break; 101 case "coops_coh": 102 coh = coops = '+'; 103 archiveSuffix = "_coh"; 104 break; 105 default: throw new RuntimeException("Invalid argument " + args[0]); 106 } 107 108 ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( 109 "-XX:+UnlockExperimentalVMOptions", 110 "-XX:" + coh + "UseCompactObjectHeaders", 111 "-XX:" + coops + "UseCompressedOops", 112 "-Xlog:cds", 113 "-Xshare:on", // fail if we cannot load archive 114 "-version"); 115 116 OutputAnalyzer output = new OutputAnalyzer(pb.start()); 117 output.shouldHaveExitValue(0); 118 119 output.shouldContain("classes" + archiveSuffix + ".jsa"); 120 121 } 122 }