hotspot/test/runtime/8003720/Asmator.java
changeset 14582 490bb6c0df7c
child 14589 a6649fc2f41d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/8003720/Asmator.java	Tue Nov 27 10:13:20 2012 +0100
@@ -0,0 +1,31 @@
+import com.sun.xml.internal.ws.org.objectweb.asm.*;
+
+class Asmator {
+    static byte[] fixup(byte[] buf) throws java.io.IOException {
+        ClassReader cr = new ClassReader(buf);
+        ClassWriter cw = new ClassWriter(0) {
+            public MethodVisitor visitMethod(
+                final int access,
+                final String name,
+                final String desc,
+                final String signature,
+                final String[] exceptions)
+            {
+                MethodVisitor mv = super.visitMethod(access,
+                        name,
+                        desc,
+                        signature,
+                        exceptions);
+                if (mv == null)  return null;
+                if (name.equals("callme")) {
+                    // make receiver go dead!
+                    mv.visitInsn(Opcodes.ACONST_NULL);
+                    mv.visitVarInsn(Opcodes.ASTORE, 0);
+                }
+                return mv;
+            }
+        };
+        cr.accept(cw, 0);
+        return cw.toByteArray();
+    }
+}