26 * @bug 8038636 |
26 * @bug 8038636 |
27 * @library /testlibrary |
27 * @library /testlibrary |
28 * @modules java.base/jdk.internal.misc |
28 * @modules java.base/jdk.internal.misc |
29 * java.instrument |
29 * java.instrument |
30 * java.management |
30 * java.management |
31 * @build compiler.profiling.spectrapredefineclass_classloaders.Agent |
31 * @build compiler.profiling.spectrapredefineclass.Agent |
32 * @run driver ClassFileInstaller compiler.profiling.spectrapredefineclass.Agent |
32 * @run driver ClassFileInstaller compiler.profiling.spectrapredefineclass.Agent |
33 * @run driver compiler.profiling.spectrapredefineclass.Launcher |
33 * @run driver compiler.profiling.spectrapredefineclass.Launcher |
34 * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation |
34 * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation |
35 * -XX:-UseOnStackReplacement -XX:TypeProfileLevel=222 |
35 * -XX:-UseOnStackReplacement -XX:TypeProfileLevel=222 |
36 * -XX:ReservedCodeCacheSize=3M |
36 * -XX:ReservedCodeCacheSize=3M |
37 * compiler.profiling.spectrapredefineclass.Agent |
37 * compiler.profiling.spectrapredefineclass.Agent |
38 */ |
38 */ |
39 |
39 |
40 package compiler.profiling.spectrapredefineclass; |
40 package compiler.profiling.spectrapredefineclass; |
41 |
41 |
42 import jdk.test.lib.JDKToolFinder; |
42 import jdk.test.lib.JDKToolLauncher; |
|
43 import jdk.test.lib.OutputAnalyzer; |
43 |
44 |
44 import java.io.File; |
45 import java.io.File; |
|
46 import java.io.IOException; |
45 import java.io.PrintWriter; |
47 import java.io.PrintWriter; |
46 |
48 |
47 public class Launcher { |
49 public class Launcher { |
|
50 private static final String MANIFEST = "MANIFEST.MF"; |
48 public static void main(String[] args) throws Exception { |
51 public static void main(String[] args) throws Exception { |
|
52 try (PrintWriter pw = new PrintWriter(MANIFEST)) { |
|
53 pw.println("Agent-Class: " + Agent.class.getName()); |
|
54 pw.println("Can-Retransform-Classes: true"); |
|
55 } |
49 |
56 |
50 PrintWriter pw = new PrintWriter("MANIFEST.MF"); |
57 JDKToolLauncher jar = JDKToolLauncher.create("jar") |
51 pw.println("Agent-Class: " + Launcher.class.getPackage().getName() +".Agent"); |
58 .addToolArg("cmf") |
52 pw.println("Can-Retransform-Classes: true"); |
59 .addToolArg(MANIFEST) |
53 pw.close(); |
60 .addToolArg(Agent.AGENT_JAR) |
|
61 .addToolArg(Agent.class.getName().replace('.', File.separatorChar) + ".class"); |
54 |
62 |
55 ProcessBuilder pb = new ProcessBuilder(); |
63 ProcessBuilder pb = new ProcessBuilder(jar.getCommand()); |
56 pb.command(new String[] { JDKToolFinder.getJDKTool("jar"), "cmf", "MANIFEST.MF", |
64 try { |
57 System.getProperty("test.classes",".") + "/agent.jar", |
65 OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
58 "compiler/profiling/spectrapredefineclass/Agent.class".replace('/', File.separatorChar)}); |
66 output.shouldHaveExitValue(0); |
59 pb.start().waitFor(); |
67 } catch (IOException ex) { |
|
68 throw new Error("TESTBUG: jar failed.", ex); |
|
69 } |
60 } |
70 } |
61 } |
71 } |