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

test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddOpens.java

Print this page




  73         Path srcJar = moduleDir.resolve(TEST_MODULE1 + ".jar");
  74         destJar = moduleDir2.resolve(TEST_MODULE1 + ".jar");
  75         String classes = MODS_DIR.resolve(TEST_MODULE1).toString();
  76         JarBuilder.createModularJar(srcJar.toString(), classes, MAIN_CLASS);
  77         Files.copy(srcJar, destJar);
  78 
  79     }
  80 
  81     public static void main(String... args) throws Exception {
  82         // compile the modules and create the modular jar files
  83         buildTestModule();
  84         String appClasses[] = {MAIN_CLASS};
  85         // create an archive with both -cp and --module-path in the command line.
  86         // Only the class in the modular jar in the --module-path will be archived;
  87         // the class in the modular jar in the -cp won't be archived.
  88         OutputAnalyzer output = TestCommon.createArchive(
  89                                         destJar.toString(), appClasses,
  90                                         "-Xlog:class+load=trace", "-XX:+PrintSystemDictionaryAtExit",
  91                                         "--module-path", moduleDir.toString(),
  92                                         "-m", TEST_MODULE1);
  93         TestCommon.checkExecReturn(output, 0, true, "Loading classes to share");
  94 
  95         // run with the archive using the same command line as in dump time
  96         // plus the "--add-opens java.base/java.lang=com.simple" option.
  97         // The main class should be loaded from the archive.
  98         // The setaccessible(true) on the ClassLoader.defineClass method should
  99         // be successful.
 100         output = TestCommon.execCommon( "-Xlog:class+load=trace",
 101                                         "-cp", destJar.toString(),
 102                                         "--add-opens", "java.base/java.lang=" + TEST_MODULE1,
 103                                         "--module-path", moduleDir.toString(),
 104                                         "-m", TEST_MODULE1, "with_add_opens");
 105         TestCommon.checkExecReturn(output, 0, true,
 106               "[class,load] com.simple.Main source: shared objects file",
 107               "method.setAccessible succeeded!");
 108 
 109     }
 110 }


  73         Path srcJar = moduleDir.resolve(TEST_MODULE1 + ".jar");
  74         destJar = moduleDir2.resolve(TEST_MODULE1 + ".jar");
  75         String classes = MODS_DIR.resolve(TEST_MODULE1).toString();
  76         JarBuilder.createModularJar(srcJar.toString(), classes, MAIN_CLASS);
  77         Files.copy(srcJar, destJar);
  78 
  79     }
  80 
  81     public static void main(String... args) throws Exception {
  82         // compile the modules and create the modular jar files
  83         buildTestModule();
  84         String appClasses[] = {MAIN_CLASS};
  85         // create an archive with both -cp and --module-path in the command line.
  86         // Only the class in the modular jar in the --module-path will be archived;
  87         // the class in the modular jar in the -cp won't be archived.
  88         OutputAnalyzer output = TestCommon.createArchive(
  89                                         destJar.toString(), appClasses,
  90                                         "-Xlog:class+load=trace", "-XX:+PrintSystemDictionaryAtExit",
  91                                         "--module-path", moduleDir.toString(),
  92                                         "-m", TEST_MODULE1);
  93         TestCommon.checkDump(output);
  94 
  95         // run with the archive using the same command line as in dump time
  96         // plus the "--add-opens java.base/java.lang=com.simple" option.
  97         // The main class should be loaded from the archive.
  98         // The setaccessible(true) on the ClassLoader.defineClass method should
  99         // be successful.
 100         TestCommon.run( "-Xlog:class+load=trace",
 101                         "-cp", destJar.toString(),
 102                         "--add-opens", "java.base/java.lang=" + TEST_MODULE1,
 103                         "--module-path", moduleDir.toString(),
 104                         "-m", TEST_MODULE1, "with_add_opens")
 105             .assertNormalExit(
 106                 "[class,load] com.simple.Main source: shared objects file",
 107                 "method.setAccessible succeeded!");
 108 
 109     }
 110 }
test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddOpens.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File