< prev index next >

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

Print this page


  76                                  MODS_DIR.resolve(MAIN_MODULE),
  77                                  MODS_DIR.toString());
  78 
  79         moduleDir = Files.createTempDirectory(USER_DIR, "mlib");
  80         moduleDir2 = Files.createTempDirectory(USER_DIR, "mlib2");
  81         subJar = moduleDir.resolve(APP_MODULE + ".jar");
  82         destJar = moduleDir2.resolve(APP_MODULE + ".jar");
  83         String classes = MODS_DIR.resolve(APP_MODULE).toString();
  84         JarBuilder.createModularJar(subJar.toString(), classes, null);
  85         Files.copy(subJar, destJar);
  86 
  87         mainJar = moduleDir.resolve(MAIN_MODULE + ".jar");
  88         Path mainJar2 = moduleDir2.resolve(MAIN_MODULE + ".jar");
  89         classes = MODS_DIR.resolve(MAIN_MODULE).toString();
  90         JarBuilder.createModularJar(mainJar.toString(), classes, MAIN_CLASS);
  91         Files.copy(mainJar, mainJar2);
  92 
  93     }
  94 
  95     public static void main(String... args) throws Exception {




  96         // compile the modules and create the modular jar files
  97         buildTestModule();
  98         String appClasses[] = {MAIN_CLASS, APP_CLASS};
  99         // create an archive with the classes in the modules built in the
 100         // previous step
 101         OutputAnalyzer output = TestCommon.createArchive(
 102                                         null, appClasses,
 103                                         "--module-path", moduleDir.toString(),
 104                                         "-m", MAIN_MODULE);
 105         TestCommon.checkDump(output);
 106         String prefix[] = {"-Djava.class.path=", "-Xlog:class+load=trace"};

 107 
 108         // run with the archive with the --module-path the same as the one during
 109         // dump time. The classes should be loaded from the archive.
 110         TestCommon.runWithModules(prefix,
 111                                   null, // --upgrade-module-path
 112                                   moduleDir.toString(), // --module-path
 113                                   MAIN_MODULE) // -m
 114             .assertNormalExit(out -> {
 115                 out.shouldContain("[class,load] com.greetings.Main source: shared objects file")
 116                    .shouldContain("[class,load] org.astro.World source: shared objects file");
 117             });
 118 
 119         // run with the archive with the --module-path different from the one during
 120         // dump time. The classes should be loaded from the jar files.
 121         TestCommon.runWithModules(prefix,
 122                                   null, // --upgrade-module-path
 123                                   moduleDir2.toString(), // --module-path
 124                                   MAIN_MODULE) // -m
 125             .assertNormalExit(out -> {
 126                 out.shouldMatch(".class.load. com.greetings.Main source:.*com.greetings.jar")




  76                                  MODS_DIR.resolve(MAIN_MODULE),
  77                                  MODS_DIR.toString());
  78 
  79         moduleDir = Files.createTempDirectory(USER_DIR, "mlib");
  80         moduleDir2 = Files.createTempDirectory(USER_DIR, "mlib2");
  81         subJar = moduleDir.resolve(APP_MODULE + ".jar");
  82         destJar = moduleDir2.resolve(APP_MODULE + ".jar");
  83         String classes = MODS_DIR.resolve(APP_MODULE).toString();
  84         JarBuilder.createModularJar(subJar.toString(), classes, null);
  85         Files.copy(subJar, destJar);
  86 
  87         mainJar = moduleDir.resolve(MAIN_MODULE + ".jar");
  88         Path mainJar2 = moduleDir2.resolve(MAIN_MODULE + ".jar");
  89         classes = MODS_DIR.resolve(MAIN_MODULE).toString();
  90         JarBuilder.createModularJar(mainJar.toString(), classes, MAIN_CLASS);
  91         Files.copy(mainJar, mainJar2);
  92 
  93     }
  94 
  95     public static void main(String... args) throws Exception {
  96         run();
  97     }
  98 
  99     public static void run(String... extra_runtime_args) throws Exception {
 100         // compile the modules and create the modular jar files
 101         buildTestModule();
 102         String appClasses[] = {MAIN_CLASS, APP_CLASS};
 103         // create an archive with the classes in the modules built in the
 104         // previous step
 105         OutputAnalyzer output = TestCommon.createArchive(
 106                                         null, appClasses,
 107                                         "--module-path", moduleDir.toString(),
 108                                         "-m", MAIN_MODULE);
 109         TestCommon.checkDump(output);
 110         String prefix[] = {"-Djava.class.path=", "-Xlog:class+load=trace"};
 111         prefix = TestCommon.concat(prefix, extra_runtime_args);
 112 
 113         // run with the archive with the --module-path the same as the one during
 114         // dump time. The classes should be loaded from the archive.
 115         TestCommon.runWithModules(prefix,
 116                                   null, // --upgrade-module-path
 117                                   moduleDir.toString(), // --module-path
 118                                   MAIN_MODULE) // -m
 119             .assertNormalExit(out -> {
 120                 out.shouldContain("[class,load] com.greetings.Main source: shared objects file")
 121                    .shouldContain("[class,load] org.astro.World source: shared objects file");
 122             });
 123 
 124         // run with the archive with the --module-path different from the one during
 125         // dump time. The classes should be loaded from the jar files.
 126         TestCommon.runWithModules(prefix,
 127                                   null, // --upgrade-module-path
 128                                   moduleDir2.toString(), // --module-path
 129                                   MAIN_MODULE) // -m
 130             .assertNormalExit(out -> {
 131                 out.shouldMatch(".class.load. com.greetings.Main source:.*com.greetings.jar")


< prev index next >