1 /* 2 * Copyright (c) 2021, 2023, 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 import java.io.File; 25 26 import jdk.test.lib.JDKToolFinder; 27 import jdk.test.lib.Platform; 28 import jdk.test.lib.process.*; 29 import jdk.test.whitebox.WhiteBox; 30 31 import tests.Helper; 32 33 import jtreg.SkippedException; 34 35 /* @test 36 * @bug 8264322 37 * @summary Test the --generate-cds-archive plugin 38 * @requires vm.cds 39 * @library ../../lib 40 * @library /test/lib 41 * @modules java.base/jdk.internal.jimage 42 * jdk.jdeps/com.sun.tools.classfile 43 * jdk.jlink/jdk.tools.jlink.internal 44 * jdk.jlink/jdk.tools.jmod 45 * jdk.jlink/jdk.tools.jimage 46 * jdk.compiler 47 * @build tests.* 48 * @build jdk.test.whitebox.WhiteBox 49 * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox 50 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. CDSPluginTest 51 */ 52 53 public class CDSPluginTest { 54 55 public static void main(String[] args) throws Throwable { 56 57 if (!Platform.isDefaultCDSArchiveSupported()) 58 throw new SkippedException("not a supported platform"); 59 60 Helper helper = Helper.newHelper(); 61 if (helper == null) { 62 System.err.println("Test not run"); 63 return; 64 } 65 66 var module = "cds"; 67 helper.generateDefaultJModule(module); 68 var image = helper.generateDefaultImage(new String[] { "--generate-cds-archive" }, 69 module) 70 .assertSuccess(); 71 72 String subDir; 73 String sep = File.separator; 74 if (Platform.isWindows()) { 75 subDir = "bin" + sep; 76 } else { 77 subDir = "lib" + sep; 78 } 79 subDir += "server" + sep; 80 81 boolean COMPACT_HEADERS = 82 Platform.is64bit() && WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompactObjectHeaders"); 83 84 String suffix = COMPACT_HEADERS ? "_coh.jsa" : ".jsa"; 85 86 if (Platform.isAArch64() || Platform.isX64()) { 87 helper.checkImage(image, module, null, null, 88 new String[] { subDir + "classes" + suffix, subDir + "classes_nocoops" + suffix }); 89 } else { 90 helper.checkImage(image, module, null, null, 91 new String[] { subDir + "classes" + suffix }); 92 } 93 } 94 }