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