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




  70         moduleDir = Files.createTempDirectory(USER_DIR, "mlib");
  71         moduleDir2 = Files.createTempDirectory(USER_DIR, "mlib2");
  72 
  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",
  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 }


  70         moduleDir = Files.createTempDirectory(USER_DIR, "mlib");
  71         moduleDir2 = Files.createTempDirectory(USER_DIR, "mlib2");
  72 
  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                                         "--module-path", moduleDir.toString(),
  91                                         "-m", TEST_MODULE1);
  92         TestCommon.checkDump(output);
  93 
  94         // run with the archive using the same command line as in dump time
  95         // plus the "--add-opens java.base/java.lang=com.simple" option.
  96         // The main class should be loaded from the archive.
  97         // The setaccessible(true) on the ClassLoader.defineClass method should
  98         // be successful.
  99         TestCommon.run( "-Xlog:class+load=trace",
 100                         "-cp", destJar.toString(),
 101                         "--add-opens", "java.base/java.lang=" + TEST_MODULE1,
 102                         "--module-path", moduleDir.toString(),
 103                         "-m", TEST_MODULE1, "with_add_opens")
 104             .assertNormalExit(
 105                 "[class,load] com.simple.Main source: shared objects file",
 106                 "method.setAccessible succeeded!");
 107 
 108     }
 109 }
test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddOpens.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File