hotspot/test/runtime/8003720/Asmator.java
changeset 14582 490bb6c0df7c
child 14589 a6649fc2f41d
equal deleted inserted replaced
14581:8427edf5a77b 14582:490bb6c0df7c
       
     1 import com.sun.xml.internal.ws.org.objectweb.asm.*;
       
     2 
       
     3 class Asmator {
       
     4     static byte[] fixup(byte[] buf) throws java.io.IOException {
       
     5         ClassReader cr = new ClassReader(buf);
       
     6         ClassWriter cw = new ClassWriter(0) {
       
     7             public MethodVisitor visitMethod(
       
     8                 final int access,
       
     9                 final String name,
       
    10                 final String desc,
       
    11                 final String signature,
       
    12                 final String[] exceptions)
       
    13             {
       
    14                 MethodVisitor mv = super.visitMethod(access,
       
    15                         name,
       
    16                         desc,
       
    17                         signature,
       
    18                         exceptions);
       
    19                 if (mv == null)  return null;
       
    20                 if (name.equals("callme")) {
       
    21                     // make receiver go dead!
       
    22                     mv.visitInsn(Opcodes.ACONST_NULL);
       
    23                     mv.visitVarInsn(Opcodes.ASTORE, 0);
       
    24                 }
       
    25                 return mv;
       
    26             }
       
    27         };
       
    28         cr.accept(cw, 0);
       
    29         return cw.toByteArray();
       
    30     }
       
    31 }