test/runtime/8003720/Asmator.java

Thu, 01 May 2014 14:57:02 -0700

author
amurillo
date
Thu, 01 May 2014 14:57:02 -0700
changeset 6651
4bc28e6b9aba
parent 4305
dad48145e775
child 6876
710a3c8b516e
permissions
-rw-r--r--

Added tag hs25.20-b13 for changeset 798f5b02be89

stefank@4305 1 /*
stefank@4305 2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
stefank@4305 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
stefank@4305 4 *
stefank@4305 5 * This code is free software; you can redistribute it and/or modify it
stefank@4305 6 * under the terms of the GNU General Public License version 2 only, as
stefank@4305 7 * published by the Free Software Foundation.
stefank@4305 8 *
stefank@4305 9 * This code is distributed in the hope that it will be useful, but WITHOUT
stefank@4305 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
stefank@4305 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
stefank@4305 12 * version 2 for more details (a copy is included in the LICENSE file that
stefank@4305 13 * accompanied this code).
stefank@4305 14 *
stefank@4305 15 * You should have received a copy of the GNU General Public License version
stefank@4305 16 * 2 along with this work; if not, write to the Free Software Foundation,
stefank@4305 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
stefank@4305 18 *
stefank@4305 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
stefank@4305 20 * or visit www.oracle.com if you need additional information or have any
stefank@4305 21 * questions.
stefank@4305 22 *
stefank@4305 23 */
stefank@4305 24
stefank@4305 25 import jdk.internal.org.objectweb.asm.*;
stefank@4298 26
stefank@4298 27 class Asmator {
stefank@4298 28 static byte[] fixup(byte[] buf) throws java.io.IOException {
stefank@4298 29 ClassReader cr = new ClassReader(buf);
stefank@4305 30 ClassWriter cw = new ClassWriter(0);
stefank@4305 31 ClassVisitor cv = new ClassVisitor(Opcodes.ASM4, cw) {
stefank@4298 32 public MethodVisitor visitMethod(
stefank@4298 33 final int access,
stefank@4298 34 final String name,
stefank@4298 35 final String desc,
stefank@4298 36 final String signature,
stefank@4298 37 final String[] exceptions)
stefank@4298 38 {
stefank@4298 39 MethodVisitor mv = super.visitMethod(access,
stefank@4298 40 name,
stefank@4298 41 desc,
stefank@4298 42 signature,
stefank@4298 43 exceptions);
stefank@4298 44 if (mv == null) return null;
stefank@4298 45 if (name.equals("callme")) {
stefank@4298 46 // make receiver go dead!
stefank@4298 47 mv.visitInsn(Opcodes.ACONST_NULL);
stefank@4298 48 mv.visitVarInsn(Opcodes.ASTORE, 0);
stefank@4298 49 }
stefank@4298 50 return mv;
stefank@4298 51 }
stefank@4298 52 };
stefank@4305 53 cr.accept(cv, 0);
stefank@4298 54 return cw.toByteArray();
stefank@4298 55 }
stefank@4298 56 }

mercurial