49 private static final Path USER_DIR = Paths.get(CDSTestUtils.getOutputDir());
50
51 private static final Path SRC_DIR = Paths.get(System.getProperty("test.src")).
52 resolve( ".." + SEP + "jigsaw" + SEP + "modulepath" + SEP + "src");
53
54 private static final Path MODS_DIR = Paths.get("mods");
55
56 // the module name of the test module
57 private static final String TEST_MODULE1 = "com.simple";
58
59 // the module main class
60 private static final String MAIN_CLASS = "com.simple.Main";
61
62 private static Path moduleDir = null;
63 private static Path moduleDir2 = null;
64 private static Path destJar = null;
65
66 private static String addOpensArg = "java.base/java.lang=" + TEST_MODULE1;
67 private static String addOpensAllUnnamed = "java.base/java.lang=ALL-UNNAMED";
68 private static String extraOpts[][] =
69 {{"-Xlog:cds", "-Xlog:cds"},
70 {"--add-opens", addOpensArg}};
71 private static String expectedOutput[] =
72 { "[class,load] com.simple.Main source: shared objects file",
73 "method.setAccessible succeeded!"};
74
75 public static void buildTestModule() throws Exception {
76
77 // javac -d mods/$TESTMODULE --module-path MOD_DIR src/$TESTMODULE/**
78 JarBuilder.compileModule(SRC_DIR.resolve(TEST_MODULE1),
79 MODS_DIR.resolve(TEST_MODULE1),
80 MODS_DIR.toString());
81
82 moduleDir = Files.createTempDirectory(USER_DIR, "mlib");
83 moduleDir2 = Files.createTempDirectory(USER_DIR, "mlib2");
84
85 Path srcJar = moduleDir.resolve(TEST_MODULE1 + ".jar");
86 destJar = moduleDir2.resolve(TEST_MODULE1 + ".jar");
87 String classes = MODS_DIR.resolve(TEST_MODULE1).toString();
88 JarBuilder.createModularJar(srcJar.toString(), classes, MAIN_CLASS);
89 Files.copy(srcJar, destJar);
103 return tester
104 .setAssemblyChecker((OutputAnalyzer out) -> {
105 out.shouldContain("Full module graph = enabled");
106 })
107 .setProductionChecker((OutputAnalyzer out) -> {
108 out.shouldContain(expectedOutput[0]);
109 out.shouldContain(expectedOutput[1]);
110 })
111 .runStaticWorkflow()
112 .runAOTWorkflow();
113 }
114
115 static class Tester1 extends CDSAppTester {
116 public Tester1(String testName) {
117 super(testName);
118 }
119
120 @Override
121 public String[] vmArgs(RunMode runMode) {
122 if (runMode == RunMode.DUMP_STATIC) {
123 return new String[] { "-Xlog:cds" };
124 } else {
125 return new String[] {
126 "--add-opens", addOpensArg, "-Xlog:class+load=trace",
127 };
128 }
129 }
130
131 @Override
132 public String classpath(RunMode runMode) {
133 return destJar.toString();
134 }
135
136 @Override
137 public String modulepath(RunMode runMode) {
138 return moduleDir.toString();
139 }
140
141 @Override
142 public String[] appCommandLine(RunMode runMode) {
143 if (runMode == RunMode.TRAINING ||
|
49 private static final Path USER_DIR = Paths.get(CDSTestUtils.getOutputDir());
50
51 private static final Path SRC_DIR = Paths.get(System.getProperty("test.src")).
52 resolve( ".." + SEP + "jigsaw" + SEP + "modulepath" + SEP + "src");
53
54 private static final Path MODS_DIR = Paths.get("mods");
55
56 // the module name of the test module
57 private static final String TEST_MODULE1 = "com.simple";
58
59 // the module main class
60 private static final String MAIN_CLASS = "com.simple.Main";
61
62 private static Path moduleDir = null;
63 private static Path moduleDir2 = null;
64 private static Path destJar = null;
65
66 private static String addOpensArg = "java.base/java.lang=" + TEST_MODULE1;
67 private static String addOpensAllUnnamed = "java.base/java.lang=ALL-UNNAMED";
68 private static String extraOpts[][] =
69 {{"-Xlog:aot,cds"},
70 {"--add-opens", addOpensArg}};
71 private static String expectedOutput[] =
72 { "[class,load] com.simple.Main source: shared objects file",
73 "method.setAccessible succeeded!"};
74
75 public static void buildTestModule() throws Exception {
76
77 // javac -d mods/$TESTMODULE --module-path MOD_DIR src/$TESTMODULE/**
78 JarBuilder.compileModule(SRC_DIR.resolve(TEST_MODULE1),
79 MODS_DIR.resolve(TEST_MODULE1),
80 MODS_DIR.toString());
81
82 moduleDir = Files.createTempDirectory(USER_DIR, "mlib");
83 moduleDir2 = Files.createTempDirectory(USER_DIR, "mlib2");
84
85 Path srcJar = moduleDir.resolve(TEST_MODULE1 + ".jar");
86 destJar = moduleDir2.resolve(TEST_MODULE1 + ".jar");
87 String classes = MODS_DIR.resolve(TEST_MODULE1).toString();
88 JarBuilder.createModularJar(srcJar.toString(), classes, MAIN_CLASS);
89 Files.copy(srcJar, destJar);
103 return tester
104 .setAssemblyChecker((OutputAnalyzer out) -> {
105 out.shouldContain("Full module graph = enabled");
106 })
107 .setProductionChecker((OutputAnalyzer out) -> {
108 out.shouldContain(expectedOutput[0]);
109 out.shouldContain(expectedOutput[1]);
110 })
111 .runStaticWorkflow()
112 .runAOTWorkflow();
113 }
114
115 static class Tester1 extends CDSAppTester {
116 public Tester1(String testName) {
117 super(testName);
118 }
119
120 @Override
121 public String[] vmArgs(RunMode runMode) {
122 if (runMode == RunMode.DUMP_STATIC) {
123 return new String[] { "-Xlog:aot,cds" };
124 } else {
125 return new String[] {
126 "--add-opens", addOpensArg, "-Xlog:class+load=trace",
127 };
128 }
129 }
130
131 @Override
132 public String classpath(RunMode runMode) {
133 return destJar.toString();
134 }
135
136 @Override
137 public String modulepath(RunMode runMode) {
138 return moduleDir.toString();
139 }
140
141 @Override
142 public String[] appCommandLine(RunMode runMode) {
143 if (runMode == RunMode.TRAINING ||
|