hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/Launcher.java
changeset 40651 998e35976abf
parent 40059 c2304140ed64
child 40652 9e6d111b4089
equal deleted inserted replaced
40650:1f280ba7058b 40651:998e35976abf
    37  * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation
    37  * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation
    38  *                   -XX:-UseOnStackReplacement -XX:TypeProfileLevel=222
    38  *                   -XX:-UseOnStackReplacement -XX:TypeProfileLevel=222
    39  *                   -XX:ReservedCodeCacheSize=3M
    39  *                   -XX:ReservedCodeCacheSize=3M
    40  *                   compiler.profiling.spectrapredefineclass_classloaders.Agent
    40  *                   compiler.profiling.spectrapredefineclass_classloaders.Agent
    41  */
    41  */
       
    42 
    42 package compiler.profiling.spectrapredefineclass_classloaders;
    43 package compiler.profiling.spectrapredefineclass_classloaders;
    43 
    44 
    44 import jdk.test.lib.JDKToolFinder;
    45 import jdk.test.lib.JDKToolLauncher;
       
    46 import jdk.test.lib.OutputAnalyzer;
    45 
    47 
    46 import java.io.File;
    48 import java.io.File;
       
    49 import java.io.IOException;
    47 import java.io.PrintWriter;
    50 import java.io.PrintWriter;
    48 
    51 
    49 public class Launcher {
    52 public class Launcher {
    50     public static void main(String[] args) throws Exception {
    53     private static final String MANIFEST = "MANIFEST.MF";
       
    54     public static void main(String[] args) throws Exception  {
       
    55         try (PrintWriter pw = new PrintWriter(MANIFEST)) {
       
    56             pw.println("Agent-Class: " + Agent.class.getName());
       
    57             pw.println("Can-Retransform-Classes: true");
       
    58         }
    51 
    59 
    52         PrintWriter pw = new PrintWriter("MANIFEST.MF");
    60         JDKToolLauncher jar = JDKToolLauncher.create("jar")
       
    61                 .addToolArg("cmf")
       
    62                 .addToolArg(MANIFEST)
       
    63                 .addToolArg(Agent.AGENT_JAR)
       
    64                 .addToolArg(Agent.class.getName().replace('.', File.separatorChar) + ".class");
    53 
    65 
    54         pw.println("Agent-Class: " + Launcher.class.getPackage().getName() + ".Agent");
    66         ProcessBuilder pb = new ProcessBuilder(jar.getCommand());
    55         pw.println("Can-Retransform-Classes: true");
    67         try {
    56         pw.close();
    68             OutputAnalyzer output = new OutputAnalyzer(pb.start());
    57 
    69             output.shouldHaveExitValue(0);
    58         ProcessBuilder pb = new ProcessBuilder();
    70         } catch (IOException ex) {
    59         pb.command(new String[]{JDKToolFinder.getJDKTool("jar"), "cmf", "MANIFEST.MF",
    71             throw new Error("TESTBUG: jar failed.", ex);
    60                 System.getProperty("test.classes", ".") + "/agent.jar",
    72         }
    61                 "compiler/profiling/spectrapredefineclass/Agent.class".replace('/', File.separatorChar)});
       
    62         pb.start().waitFor();
       
    63     }
    73     }
    64 }
    74 }