< prev index next >

test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClasses.java

Print this page

155         // as the agent returns a buffer, it will not load the class from CDS, and will instead
156         // load the class by parsing the buffer.
157         //
158         // Note that for safety we don't change the contents of the class file bytes. If in the
159         // future JVMTI starts checking the contents of the class file bytes, this test would need
160         // to be updated. (You'd see the test case with java/util/Locale staring to fail).
161         String agent = "-agentlib:SimpleClassFileLoadHook=" + early + klassName + ",XXX,XXX";
162 
163         CDSOptions opts = (new CDSOptions())
164             .setXShareMode("auto")
165             .setArchiveName(ReplaceCriticalClasses.class.getName() + ".jsa")
166             .setUseVersion(false)
167             .addSuffix("-showversion",
168                        "-Xlog:cds",
169                        "-XX:+UnlockDiagnosticVMOptions",
170                        agent);
171         if (whitebox) {
172             opts.addSuffix("-XX:+WhiteBoxAPI",
173                            "-Xbootclasspath/a:" + ClassFileInstaller.getJarPath("whitebox.jar"));
174         }
175         if (subgraph) {
176             opts.addSuffix("-Xlog:cds,cds+heap");
177         }
178 
179         opts.addSuffix("ReplaceCriticalClasses",
180                        "child",
181                        shared,
182                        klassName);
183 
184         final boolean expectDisable = !early.equals("");
185         final boolean checkSubgraph = subgraph;
186         final boolean expectShared = shared.equals("-shared");
187         CDSTestUtils.run(opts).assertNormalExit(out -> {
188                 if (expectDisable) {
189                     out.shouldContain("UseSharedSpaces: CDS is disabled because early JVMTI ClassFileLoadHook is in use.");
190                     System.out.println("CDS disabled as expected");
191                 }
192                 if (checkSubgraph) {
193                     if (expectShared) {
194                         if (!out.getOutput().contains("UseSharedSpaces: Unable to map at required address in java heap")) {
195                             out.shouldContain(subgraphInit);
196                             // If the subgraph is successfully initialized, the specified shared class must not be rewritten.
197                             out.shouldNotContain("Rewriting done.");
198                         }

155         // as the agent returns a buffer, it will not load the class from CDS, and will instead
156         // load the class by parsing the buffer.
157         //
158         // Note that for safety we don't change the contents of the class file bytes. If in the
159         // future JVMTI starts checking the contents of the class file bytes, this test would need
160         // to be updated. (You'd see the test case with java/util/Locale staring to fail).
161         String agent = "-agentlib:SimpleClassFileLoadHook=" + early + klassName + ",XXX,XXX";
162 
163         CDSOptions opts = (new CDSOptions())
164             .setXShareMode("auto")
165             .setArchiveName(ReplaceCriticalClasses.class.getName() + ".jsa")
166             .setUseVersion(false)
167             .addSuffix("-showversion",
168                        "-Xlog:cds",
169                        "-XX:+UnlockDiagnosticVMOptions",
170                        agent);
171         if (whitebox) {
172             opts.addSuffix("-XX:+WhiteBoxAPI",
173                            "-Xbootclasspath/a:" + ClassFileInstaller.getJarPath("whitebox.jar"));
174         }
175         opts.addSuffix("-Xlog:cds,cds+heap");



176         opts.addSuffix("ReplaceCriticalClasses",
177                        "child",
178                        shared,
179                        klassName);
180 
181         final boolean expectDisable = !early.equals("");
182         final boolean checkSubgraph = subgraph;
183         final boolean expectShared = shared.equals("-shared");
184         CDSTestUtils.run(opts).assertNormalExit(out -> {
185                 if (expectDisable) {
186                     out.shouldContain("UseSharedSpaces: CDS is disabled because early JVMTI ClassFileLoadHook is in use.");
187                     System.out.println("CDS disabled as expected");
188                 }
189                 if (checkSubgraph) {
190                     if (expectShared) {
191                         if (!out.getOutput().contains("UseSharedSpaces: Unable to map at required address in java heap")) {
192                             out.shouldContain(subgraphInit);
193                             // If the subgraph is successfully initialized, the specified shared class must not be rewritten.
194                             out.shouldNotContain("Rewriting done.");
195                         }
< prev index next >