hotspot/test/compiler/jsr292/RedefineMethodUsedByMultipleMethodHandles.java
changeset 42309 21f9f3fbc302
parent 40059 c2304140ed64
child 44993 f61bcd80ec1f
equal deleted inserted replaced
42308:45166b2aac44 42309:21f9f3fbc302
    28  * @library /
    28  * @library /
    29  * @modules java.base/jdk.internal.org.objectweb.asm
    29  * @modules java.base/jdk.internal.org.objectweb.asm
    30  *          java.compiler
    30  *          java.compiler
    31  *          java.instrument
    31  *          java.instrument
    32  *          java.management
    32  *          java.management
       
    33  *          jdk.attach
    33  *
    34  *
    34  * @run main/othervm compiler.jsr292.RedefineMethodUsedByMultipleMethodHandles
    35  * @run main/othervm compiler.jsr292.RedefineMethodUsedByMultipleMethodHandles
    35  */
    36  */
    36 
    37 
    37 package compiler.jsr292;
    38 package compiler.jsr292;
    40 import jdk.internal.org.objectweb.asm.ClassVisitor;
    41 import jdk.internal.org.objectweb.asm.ClassVisitor;
    41 import jdk.internal.org.objectweb.asm.ClassWriter;
    42 import jdk.internal.org.objectweb.asm.ClassWriter;
    42 import jdk.internal.org.objectweb.asm.MethodVisitor;
    43 import jdk.internal.org.objectweb.asm.MethodVisitor;
    43 import jdk.internal.org.objectweb.asm.Opcodes;
    44 import jdk.internal.org.objectweb.asm.Opcodes;
    44 
    45 
    45 import javax.tools.ToolProvider;
       
    46 import java.io.FileOutputStream;
    46 import java.io.FileOutputStream;
    47 import java.io.IOException;
    47 import java.io.IOException;
    48 import java.io.InputStream;
    48 import java.io.InputStream;
    49 import java.lang.instrument.ClassFileTransformer;
    49 import java.lang.instrument.ClassFileTransformer;
    50 import java.lang.instrument.IllegalClassFormatException;
    50 import java.lang.instrument.IllegalClassFormatException;
   130     public static void runAgent(Path agent) throws Exception {
   130     public static void runAgent(Path agent) throws Exception {
   131         String vmName = ManagementFactory.getRuntimeMXBean().getName();
   131         String vmName = ManagementFactory.getRuntimeMXBean().getName();
   132         int p = vmName.indexOf('@');
   132         int p = vmName.indexOf('@');
   133         assert p != -1 : "VM name not in <pid>@<host> format: " + vmName;
   133         assert p != -1 : "VM name not in <pid>@<host> format: " + vmName;
   134         String pid = vmName.substring(0, p);
   134         String pid = vmName.substring(0, p);
   135         ClassLoader cl = ToolProvider.getSystemToolClassLoader();
   135         ClassLoader cl = ClassLoader.getSystemClassLoader();
   136         Class<?> c = Class.forName("com.sun.tools.attach.VirtualMachine", true, cl);
   136         Class<?> c = Class.forName("com.sun.tools.attach.VirtualMachine", true, cl);
   137         Method attach = c.getDeclaredMethod("attach", String.class);
   137         Method attach = c.getDeclaredMethod("attach", String.class);
   138         Method loadAgent = c.getDeclaredMethod("loadAgent", String.class);
   138         Method loadAgent = c.getDeclaredMethod("loadAgent", String.class);
   139         Method detach = c.getDeclaredMethod("detach");
   139         Method detach = c.getDeclaredMethod("detach");
   140         Object vm = attach.invoke(null, pid);
   140         Object vm = attach.invoke(null, pid);