1 #!/bin/bash 2 # Copyright (c) 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 echo "// --- start auto-generated" 25 26 testnames=( MethodHandlesGeneralTest MethodHandlesAsCollectorTest MethodHandlesCastFailureTest MethodHandlesInvokersTest MethodHandlesPermuteArgumentsTest MethodHandlesSpreadArgumentsTest ) 27 name_suffix='.java' 28 29 for i in "${testnames[@]}" 30 do 31 fname="$i$name_suffix" 32 cat << EOF > $fname 33 34 // this file is auto-generated by $0. Do not edit manually. 35 36 /* 37 * @test 38 * @summary Run the $fname test in dynamic CDS archive mode. 39 * @requires vm.cds & vm.compMode != "Xcomp" 40 * @comment Some of the tests run excessively slowly with -Xcomp. The original 41 * tests aren't executed with -Xcomp in the CI pipeline, so let's exclude 42 * the generated tests from -Xcomp execution as well. 43 * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds 44 * /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive 45 * /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes 46 * @compile ../../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java 47 * ../../../../../../../lib/jdk/test/lib/Utils.java 48 * ../../../../../../../jdk/java/lang/invoke/$fname 49 * ../../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java 50 * ../../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java 51 * ../test-classes/TestMHApp.java 52 * @build sun.hotspot.WhiteBox 53 * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox\$WhiteBoxPermission 54 * @run junit/othervm/timeout=240 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. $i 55 */ 56 57 import org.junit.Test; 58 59 import java.io.File; 60 61 import jtreg.SkippedException; 62 63 import sun.hotspot.gc.GC; 64 65 public class $i extends DynamicArchiveTestBase { 66 @Test 67 public void test() throws Exception { 68 runTest($i::testImpl); 69 } 70 71 private static final String classDir = System.getProperty("test.classes"); 72 private static final String mainClass = "TestMHApp"; 73 private static final String javaClassPath = System.getProperty("java.class.path"); 74 private static final String ps = System.getProperty("path.separator"); 75 private static final String testPackageName = "test.java.lang.invoke"; 76 private static final String testClassName = "$i"; 77 private static final String skippedException = "jtreg.SkippedException: Unable to map shared archive: test did not complete"; 78 79 static void testImpl() throws Exception { 80 String topArchiveName = getNewArchiveName(); 81 JarBuilder.build("MH", new File(classDir), null); 82 String appJar = classDir + File.separator + "MH.jar"; 83 84 String[] classPaths = javaClassPath.split(File.pathSeparator); 85 String junitJar = null; 86 for (String path : classPaths) { 87 if (path.endsWith("junit.jar")) { 88 junitJar = path; 89 break; 90 } 91 } 92 93 dumpAndRun(topArchiveName, "-Xlog:cds,cds+dynamic=debug,class+load=trace", 94 "-cp", appJar + ps + junitJar, 95 mainClass, testPackageName + "." + testClassName); 96 } 97 } 98 EOF 99 done 100 echo "// --- end auto-generated"