< prev index next >

test/hotspot/jtreg/runtime/cds/appcds/jvmti/transformRelatedClasses/TransformRelatedClassesAppCDS.java

Print this page

 89     public TransformRelatedClassesAppCDS(String parent, String child) {
 90         super(parent, child);
 91 
 92         // a trick to get it compiled by jtreg
 93         CustomLoaderApp.ping();
 94     }
 95 
 96 
 97     private void prepareAgent(String[] agentClasses) throws Exception {
 98         String manifest = "../../../../../testlibrary/jvmti/TransformerAgent.mf";
 99         agentJar = ClassFileInstaller.writeJar("TransformerAgent.jar",
100                    ClassFileInstaller.Manifest.fromSourceFile(manifest),
101                                            agentClasses);
102     }
103 
104 
105     private void runWithAppLoader(ArrayList<TestEntry> testTable) throws Exception {
106         String appJar = writeJar("app", testClasses);
107 
108         // create an archive
109         OutputAnalyzer out = TestCommon.dump(appJar, testClasses);
110         TestCommon.checkDump(out);
111 
112         // execute with archive
113         for (TestEntry entry : testTable) {
114             log("runTestWithAppLoader(): testCaseId = %d", entry.testCaseId);
115             String params = TransformTestCommon.getAgentParams(entry, parent, child);
116             String agentParam = String.format("-javaagent:%s=%s", agentJar, params);
117             TestCommon.run("-Xlog:class+load=info", "-cp", appJar,
118                            agentParam, child)
119               .assertNormalExit(output -> TransformTestCommon.checkResults(entry, output, parent, child));
120         }
121     }
122 
123 
124     private String[] getCustomClassList(String loaderType, String customJar) {
125         String type = child + "-" + loaderType;
126 
127         switch (type) {
128 
129         case "SubClass-unregistered":

170         // create jar files: appJar, customJar (for custom loaders to load classes from)
171         String appJar = writeJar("custldr-app", appClasses);
172         String customJar = writeJar("custldr-custom", customClasses);
173 
174         for (TestEntry entry : testTable) {
175             log("runTestWithCustomLoader(): testCaseId = %d", entry.testCaseId);
176             // unregistered (aka FP) case
177             String[] classList = getCustomClassList("unregistered",customJar);
178             execAndCheckWithCustomLoader(entry, "unregistered", classList,
179                                          appJar, agentJar, customJar);
180         }
181     }
182 
183 
184     private void
185         execAndCheckWithCustomLoader(TestEntry entry, String loaderType,
186                                      String[] classList, String appJar,
187                                      String agentJar, String customJar)
188         throws Exception {
189 
190         OutputAnalyzer out = TestCommon.dump(appJar, classList);
191         TestCommon.checkDump(out);
192 
193         String agentParam = "-javaagent:" + agentJar + "=" +
194             TransformTestCommon.getAgentParams(entry, parent, child);
195 
196         TestCommon.run("-Xlog:class+load=info",
197                        "-cp", appJar,
198                        agentParam,
199                        "CustomLoaderApp",
200                        customJar, loaderType, child)
201           .assertNormalExit(output -> TransformTestCommon.checkResults(entry, output, parent, child));
202     }
203 
204 
205     private String writeJar(String type, String[] classes)
206         throws Exception {
207         String jarName = String.format("%s-%s.jar", child, type);
208         return ClassFileInstaller.writeJar(jarName, classes);
209     }
210 }

 89     public TransformRelatedClassesAppCDS(String parent, String child) {
 90         super(parent, child);
 91 
 92         // a trick to get it compiled by jtreg
 93         CustomLoaderApp.ping();
 94     }
 95 
 96 
 97     private void prepareAgent(String[] agentClasses) throws Exception {
 98         String manifest = "../../../../../testlibrary/jvmti/TransformerAgent.mf";
 99         agentJar = ClassFileInstaller.writeJar("TransformerAgent.jar",
100                    ClassFileInstaller.Manifest.fromSourceFile(manifest),
101                                            agentClasses);
102     }
103 
104 
105     private void runWithAppLoader(ArrayList<TestEntry> testTable) throws Exception {
106         String appJar = writeJar("app", testClasses);
107 
108         // create an archive
109         OutputAnalyzer out = TestCommon.dump(appJar, testClasses, "-XX:-PreloadSharedClasses");
110         TestCommon.checkDump(out);
111 
112         // execute with archive
113         for (TestEntry entry : testTable) {
114             log("runTestWithAppLoader(): testCaseId = %d", entry.testCaseId);
115             String params = TransformTestCommon.getAgentParams(entry, parent, child);
116             String agentParam = String.format("-javaagent:%s=%s", agentJar, params);
117             TestCommon.run("-Xlog:class+load=info", "-cp", appJar,
118                            agentParam, child)
119               .assertNormalExit(output -> TransformTestCommon.checkResults(entry, output, parent, child));
120         }
121     }
122 
123 
124     private String[] getCustomClassList(String loaderType, String customJar) {
125         String type = child + "-" + loaderType;
126 
127         switch (type) {
128 
129         case "SubClass-unregistered":

170         // create jar files: appJar, customJar (for custom loaders to load classes from)
171         String appJar = writeJar("custldr-app", appClasses);
172         String customJar = writeJar("custldr-custom", customClasses);
173 
174         for (TestEntry entry : testTable) {
175             log("runTestWithCustomLoader(): testCaseId = %d", entry.testCaseId);
176             // unregistered (aka FP) case
177             String[] classList = getCustomClassList("unregistered",customJar);
178             execAndCheckWithCustomLoader(entry, "unregistered", classList,
179                                          appJar, agentJar, customJar);
180         }
181     }
182 
183 
184     private void
185         execAndCheckWithCustomLoader(TestEntry entry, String loaderType,
186                                      String[] classList, String appJar,
187                                      String agentJar, String customJar)
188         throws Exception {
189 
190         OutputAnalyzer out = TestCommon.dump(appJar, classList, "-XX:-PreloadSharedClasses");
191         TestCommon.checkDump(out);
192 
193         String agentParam = "-javaagent:" + agentJar + "=" +
194             TransformTestCommon.getAgentParams(entry, parent, child);
195 
196         TestCommon.run("-Xlog:class+load=info",
197                        "-cp", appJar,
198                        agentParam,
199                        "CustomLoaderApp",
200                        customJar, loaderType, child)
201           .assertNormalExit(output -> TransformTestCommon.checkResults(entry, output, parent, child));
202     }
203 
204 
205     private String writeJar(String type, String[] classes)
206         throws Exception {
207         String jarName = String.format("%s-%s.jar", child, type);
208         return ClassFileInstaller.writeJar(jarName, classes);
209     }
210 }
< prev index next >