Mercurial > hg > graal-compiler
diff test/runtime/8003720/Asmator.java @ 7179:d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
Summary: Pass down a closure during root scanning to keep the class of the method alive.
Reviewed-by: coleenp, jcoomes
author | stefank |
---|---|
date | Tue, 27 Nov 2012 10:13:20 +0100 |
parents | |
children | dad48145e775 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/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(); + } +}