< prev index next >

test/hotspot/jtreg/runtime/cds/appcds/loaderConstraints/DynamicLoaderConstraintsTest.java

Print this page

  1 /*
  2  * Copyright (c) 2020, 2022, 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  */

143      *        dump time.
144      * false: At dump time, simply load all the necessary test classes without
145      *        causing LinkageError. This ensures the test classes will be
146      *        archived so we can test CDS's handling of loader constraints during
147      *        run time.
148      */
149   static void doTest(boolean errorInDump) throws Exception  {
150         for (int i = 1; i <= 3; i++) {
151             System.out.println("========================================");
152             System.out.println("errorInDump: " + errorInDump + ", useCustomLoader: " + useCustomLoader +
153                                ", useZGC: " + useZGC + ", ZGenerational: " + useZGenerational + ", case: " + i);
154             System.out.println("========================================");
155             String topArchiveName = getNewArchiveName();
156             String testCase = Integer.toString(i);
157             String cmdLine[] = new String[] {
158                 "--add-modules",
159                 "java.base,jdk.httpserver",
160                 "--add-exports",
161                 "java.base/jdk.internal.misc=ALL-UNNAMED",
162                 "-Xlog:cds=debug,class+load,class+loader+constraints",

163             };
164 
165             if (useCustomLoader) {
166                 if (useZGC) {
167                     String zGenerational = "-XX:" + (useZGenerational ? "+" : "-") + "ZGenerational";
168                     // Add options to force eager class unloading.
169                     cmdLine = TestCommon.concat(cmdLine, "-cp", loaderJar,
170                                                 "-XX:+UseZGC", zGenerational, "-XX:ZCollectionInterval=0.01",
171                                                 loaderMainClass, appJar);
172                     setBaseArchiveOptions("-XX:+UseZGC", "-Xlog:cds");
173                 } else {
174                     cmdLine = TestCommon.concat(cmdLine, "-cp", loaderJar,
175                                                 loaderMainClass, appJar);
176                 }
177             } else {
178                 cmdLine = TestCommon.concat(cmdLine, "-cp", appJar);
179             }
180 
181             cmdLine = TestCommon.concat(cmdLine, mainClass, testCase);
182 

  1 /*
  2  * Copyright (c) 2020, 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  */

143      *        dump time.
144      * false: At dump time, simply load all the necessary test classes without
145      *        causing LinkageError. This ensures the test classes will be
146      *        archived so we can test CDS's handling of loader constraints during
147      *        run time.
148      */
149   static void doTest(boolean errorInDump) throws Exception  {
150         for (int i = 1; i <= 3; i++) {
151             System.out.println("========================================");
152             System.out.println("errorInDump: " + errorInDump + ", useCustomLoader: " + useCustomLoader +
153                                ", useZGC: " + useZGC + ", ZGenerational: " + useZGenerational + ", case: " + i);
154             System.out.println("========================================");
155             String topArchiveName = getNewArchiveName();
156             String testCase = Integer.toString(i);
157             String cmdLine[] = new String[] {
158                 "--add-modules",
159                 "java.base,jdk.httpserver",
160                 "--add-exports",
161                 "java.base/jdk.internal.misc=ALL-UNNAMED",
162                 "-Xlog:cds=debug,class+load,class+loader+constraints",
163                 "-XX:-PreloadSharedClasses",
164             };
165 
166             if (useCustomLoader) {
167                 if (useZGC) {
168                     String zGenerational = "-XX:" + (useZGenerational ? "+" : "-") + "ZGenerational";
169                     // Add options to force eager class unloading.
170                     cmdLine = TestCommon.concat(cmdLine, "-cp", loaderJar,
171                                                 "-XX:+UseZGC", zGenerational, "-XX:ZCollectionInterval=0.01",
172                                                 loaderMainClass, appJar);
173                     setBaseArchiveOptions("-XX:+UseZGC", "-Xlog:cds");
174                 } else {
175                     cmdLine = TestCommon.concat(cmdLine, "-cp", loaderJar,
176                                                 loaderMainClass, appJar);
177                 }
178             } else {
179                 cmdLine = TestCommon.concat(cmdLine, "-cp", appJar);
180             }
181 
182             cmdLine = TestCommon.concat(cmdLine, mainClass, testCase);
183 
< prev index next >