test/hotspot/jtreg/runtime/appcds/jigsaw/classpathtests/BootAppendTests.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File open Sdiff test/hotspot/jtreg/runtime/appcds/jigsaw/classpathtests

test/hotspot/jtreg/runtime/appcds/jigsaw/classpathtests/BootAppendTests.java

Print this page


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


 130     }
 131 
 132     // Test #2: A shared class in package defined in boot module that's archived
 133     //          from -Xbootclasspath/a
 134     //     - should not be loaded by AppCDS
 135     public static void testBootAppendModuleClassWithAppCDS() throws Exception {
 136         OutputAnalyzer output = TestCommon.exec(
 137             appJar,
 138             "-Xbootclasspath/a:" + bootAppendJar,
 139             MAIN_CLASS,
 140             "Test #2", BOOT_APPEND_MODULE_CLASS, "false");
 141         TestCommon.checkExec(output);
 142     }
 143 
 144 
 145     // Test #3: A class in excluded package defined in boot module
 146     //     - should be loaded from the -Xbootclasspath/a by the boot classloader
 147     public static void testBootAppendExcludedModuleClassWithoutAppCDS() throws Exception {
 148         CDSOptions opts = (new CDSOptions())
 149             .addPrefix("-Xbootclasspath/a:" + bootAppendJar, "-cp", appJar,

 150                        "--limit-modules", "java.base")
 151             .setArchiveName(testArchiveName)

 152             .addSuffix(MAIN_CLASS, "Test #3", BOOT_APPEND_MODULE_CLASS, "true", "BOOT");
 153 
 154         CDSTestUtils.runWithArchiveAndCheck(opts);



 155     }
 156 
 157     // Test #4: A shared class in excluded package that's archived from
 158     //          -Xbootclasspath/a
 159     //     - should be loaded from the archive by the bootstrap classloader

 160     public static void testBootAppendExcludedModuleClassWithAppCDS() throws Exception {
 161         OutputAnalyzer output = TestCommon.exec(
 162             appJar,
 163             "-Xbootclasspath/a:" + bootAppendJar,
 164             "--limit-modules", "java.base",
 165             "-XX:+TraceClassLoading",
 166             MAIN_CLASS,
 167             "Test #4", BOOT_APPEND_MODULE_CLASS, "true", "BOOT");
 168         TestCommon.checkExec(output);
 169         if (!TestCommon.isUnableToMap(output))
 170             output.shouldContain("[class,load] sun.nio.cs.ext.MyClass source: shared objects file");
 171     }
 172 
 173 
 174     // Test #5: A class not in package defined in boot module
 175     //    - should be loaded from the -Xbootclasspath/a without AppCDS
 176     public static void testBootAppendClassWithoutAppCDS() throws Exception {
 177         CDSOptions opts = (new CDSOptions())
 178             .addPrefix("-Xbootclasspath/a:" + bootAppendJar, "-cp", appJar)
 179             .setArchiveName(testArchiveName)
 180             .addSuffix(MAIN_CLASS, "Test #5", BOOT_APPEND_CLASS, "true", "BOOT");
 181 
 182         CDSTestUtils.runWithArchiveAndCheck(opts);
 183     }
 184 
 185 
 186     // Test #6: A shared class not in package defined in boot module that's
 187     //          archived from -Xbootclasspath/a
 188     //    - should be loaded from the archive by the bootstrap class loader
 189     public static void testBootAppendClassWithAppCDS() throws Exception {
 190         OutputAnalyzer output = TestCommon.exec(


 214     // Test #8: A shared class in package defined in jimage app module that's
 215     //          archived from -Xbootclasspath/a
 216     //    - should not be loaded from the archive
 217     public static void testBootAppendAppModuleClassWithAppCDS() throws Exception {
 218         OutputAnalyzer output = TestCommon.exec(
 219             appJar,
 220             "-Xbootclasspath/a:" + bootAppendJar,
 221             MAIN_CLASS,
 222             "Test #8", APP_MODULE_CLASS, "false");
 223         TestCommon.checkExec(output);
 224     }
 225 
 226 
 227     // Test #9: A class in excluded package defined in jimage app module
 228     //    - should be loaded from the -Xbootclasspath/a without AppCDS
 229     public static void testBootAppendAppExcludeModuleClassWithoutAppCDS()
 230         throws Exception {
 231 
 232         CDSOptions opts = (new CDSOptions())
 233             .addPrefix("-Xbootclasspath/a:" + bootAppendJar, "-cp", appJar,

 234                        "--limit-modules", "java.base")
 235             .setArchiveName(testArchiveName)

 236             .addSuffix(MAIN_CLASS, "Test #9", APP_MODULE_CLASS, "true", "BOOT");
 237 
 238         CDSTestUtils.runWithArchiveAndCheck(opts);



 239     }
 240 
 241     // Test #10: A shared class in excluded package defined in jimage app module
 242     //    - should be loaded from the -Xbootclasspath/a with AppCDS
 243     public static void testBootAppendAppExcludeModuleClassAppCDS() throws Exception {
 244         OutputAnalyzer output = TestCommon.exec(
 245             appJar,
 246             "-Xbootclasspath/a:" + bootAppendJar,
 247             "-XX:+TraceClassLoading",
 248             "--limit-modules", "java.base",
 249             MAIN_CLASS,
 250             "Test #10", APP_MODULE_CLASS, "true", "BOOT");
 251         TestCommon.checkExec(output);
 252 

 253         if (!TestCommon.isUnableToMap(output))
 254             output.shouldContain("[class,load] com.sun.tools.javac.Main2 source: shared objects file");
 255     }
 256 }
   1 /*
   2  * Copyright (c) 2015, 2018, 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  *


 130     }
 131 
 132     // Test #2: A shared class in package defined in boot module that's archived
 133     //          from -Xbootclasspath/a
 134     //     - should not be loaded by AppCDS
 135     public static void testBootAppendModuleClassWithAppCDS() throws Exception {
 136         OutputAnalyzer output = TestCommon.exec(
 137             appJar,
 138             "-Xbootclasspath/a:" + bootAppendJar,
 139             MAIN_CLASS,
 140             "Test #2", BOOT_APPEND_MODULE_CLASS, "false");
 141         TestCommon.checkExec(output);
 142     }
 143 
 144 
 145     // Test #3: A class in excluded package defined in boot module
 146     //     - should be loaded from the -Xbootclasspath/a by the boot classloader
 147     public static void testBootAppendExcludedModuleClassWithoutAppCDS() throws Exception {
 148         CDSOptions opts = (new CDSOptions())
 149             .addPrefix("-Xbootclasspath/a:" + bootAppendJar, "-cp", appJar,
 150                        "-Xlog:class+load=info",
 151                        "--limit-modules", "java.base")
 152             .setArchiveName(testArchiveName)
 153             .setUseVersion(false)
 154             .addSuffix(MAIN_CLASS, "Test #3", BOOT_APPEND_MODULE_CLASS, "true", "BOOT");
 155 
 156         OutputAnalyzer output = CDSTestUtils.runWithArchive(opts);
 157         output.shouldHaveExitValue(0);
 158         if (!TestCommon.isUnableToMap(output))
 159             output.shouldMatch(".class.load. sun.nio.cs.ext.MyClass source:.*bootAppend.jar");
 160     }
 161 
 162     // Test #4: A shared class in excluded package that's archived from
 163     //          -Xbootclasspath/a
 164     //     - should be loaded from the jar since AppCDS will be disabled with
 165     //       the --limit-modules option
 166     public static void testBootAppendExcludedModuleClassWithAppCDS() throws Exception {
 167         OutputAnalyzer output = TestCommon.exec(
 168             appJar,
 169             "-Xbootclasspath/a:" + bootAppendJar,
 170             "--limit-modules", "java.base",
 171             "-XX:+TraceClassLoading",
 172             MAIN_CLASS,
 173             "Test #4", BOOT_APPEND_MODULE_CLASS, "true", "BOOT");
 174         output.shouldHaveExitValue(0);
 175         if (!TestCommon.isUnableToMap(output))
 176             output.shouldMatch(".class.load. sun.nio.cs.ext.MyClass source:.*bootAppend.jar");
 177     }
 178 
 179 
 180     // Test #5: A class not in package defined in boot module
 181     //    - should be loaded from the -Xbootclasspath/a without AppCDS
 182     public static void testBootAppendClassWithoutAppCDS() throws Exception {
 183         CDSOptions opts = (new CDSOptions())
 184             .addPrefix("-Xbootclasspath/a:" + bootAppendJar, "-cp", appJar)
 185             .setArchiveName(testArchiveName)
 186             .addSuffix(MAIN_CLASS, "Test #5", BOOT_APPEND_CLASS, "true", "BOOT");
 187 
 188         CDSTestUtils.runWithArchiveAndCheck(opts);
 189     }
 190 
 191 
 192     // Test #6: A shared class not in package defined in boot module that's
 193     //          archived from -Xbootclasspath/a
 194     //    - should be loaded from the archive by the bootstrap class loader
 195     public static void testBootAppendClassWithAppCDS() throws Exception {
 196         OutputAnalyzer output = TestCommon.exec(


 220     // Test #8: A shared class in package defined in jimage app module that's
 221     //          archived from -Xbootclasspath/a
 222     //    - should not be loaded from the archive
 223     public static void testBootAppendAppModuleClassWithAppCDS() throws Exception {
 224         OutputAnalyzer output = TestCommon.exec(
 225             appJar,
 226             "-Xbootclasspath/a:" + bootAppendJar,
 227             MAIN_CLASS,
 228             "Test #8", APP_MODULE_CLASS, "false");
 229         TestCommon.checkExec(output);
 230     }
 231 
 232 
 233     // Test #9: A class in excluded package defined in jimage app module
 234     //    - should be loaded from the -Xbootclasspath/a without AppCDS
 235     public static void testBootAppendAppExcludeModuleClassWithoutAppCDS()
 236         throws Exception {
 237 
 238         CDSOptions opts = (new CDSOptions())
 239             .addPrefix("-Xbootclasspath/a:" + bootAppendJar, "-cp", appJar,
 240                        "-Xlog:class+load=info",
 241                        "--limit-modules", "java.base")
 242             .setArchiveName(testArchiveName)
 243             .setUseVersion(false)
 244             .addSuffix(MAIN_CLASS, "Test #9", APP_MODULE_CLASS, "true", "BOOT");
 245 
 246         OutputAnalyzer output = CDSTestUtils.runWithArchive(opts);
 247         output.shouldHaveExitValue(0);
 248         if (!TestCommon.isUnableToMap(output))
 249             output.shouldMatch(".class.load. com.sun.tools.javac.Main2 source:.*bootAppend.jar");
 250     }
 251 
 252     // Test #10: A shared class in excluded package defined in jimage app module
 253     //    - should be loaded from the -Xbootclasspath/a with AppCDS
 254     public static void testBootAppendAppExcludeModuleClassAppCDS() throws Exception {
 255         OutputAnalyzer output = TestCommon.exec(
 256             appJar,
 257             "-Xbootclasspath/a:" + bootAppendJar,
 258             "-XX:+TraceClassLoading",
 259             "--limit-modules", "java.base",
 260             MAIN_CLASS,
 261             "Test #10", APP_MODULE_CLASS, "true", "BOOT");

 262 
 263         output.shouldHaveExitValue(0);
 264         if (!TestCommon.isUnableToMap(output))
 265             output.shouldMatch(".class.load. com.sun.tools.javac.Main2 source:.*bootAppend.jar");
 266     }
 267 }
test/hotspot/jtreg/runtime/appcds/jigsaw/classpathtests/BootAppendTests.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File