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