use of jdk.internal.org.objectweb.asm.MethodVisitor in project jdk8u_jdk by JetBrains.
the class MethodNode method accept.
/**
* Makes the given class visitor visit this method.
*
* @param cv
* a class visitor.
*/
public void accept(final ClassVisitor cv) {
String[] exceptions = new String[this.exceptions.size()];
this.exceptions.toArray(exceptions);
MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions);
if (mv != null) {
accept(mv);
}
}
use of jdk.internal.org.objectweb.asm.MethodVisitor in project jdk8u_jdk by JetBrains.
the class StaticInitMerger method visitMethod.
@Override
public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) {
MethodVisitor mv;
if ("<clinit>".equals(name)) {
int a = Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC;
String n = prefix + counter++;
mv = cv.visitMethod(a, n, desc, signature, exceptions);
if (clinit == null) {
clinit = cv.visitMethod(a, name, desc, null, null);
}
clinit.visitMethodInsn(Opcodes.INVOKESTATIC, this.name, n, desc, false);
} else {
mv = cv.visitMethod(access, name, desc, signature, exceptions);
}
return mv;
}
use of jdk.internal.org.objectweb.asm.MethodVisitor in project jdk8u_jdk by JetBrains.
the class RemappingClassAdapter method visitMethod.
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
String newDesc = remapper.mapMethodDesc(desc);
MethodVisitor mv = super.visitMethod(access, remapper.mapMethodName(className, name, desc), newDesc, remapper.mapSignature(signature, false), exceptions == null ? null : remapper.mapTypes(exceptions));
return mv == null ? null : createRemappingMethodAdapter(access, newDesc, mv);
}
use of jdk.internal.org.objectweb.asm.MethodVisitor in project jdk8u_jdk by JetBrains.
the class TraceClassVisitor method visitMethod.
@Override
public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) {
Printer p = this.p.visitMethod(access, name, desc, signature, exceptions);
MethodVisitor mv = cv == null ? null : cv.visitMethod(access, name, desc, signature, exceptions);
return new TraceMethodVisitor(mv, p);
}
use of jdk.internal.org.objectweb.asm.MethodVisitor in project jdk8u_jdk by JetBrains.
the class LambdaAsm method verifyASM.
static void verifyASM() throws Exception {
ClassWriter cw = new ClassWriter(0);
cw.visit(V1_8, ACC_PUBLIC, "X", null, "java/lang/Object", null);
MethodVisitor mv = cw.visitMethod(ACC_STATIC, "foo", "()V", null, null);
mv.visitMaxs(2, 1);
mv.visitMethodInsn(INVOKESTATIC, "java/util/function/Function.class", "identity", "()Ljava/util/function/Function;", true);
mv.visitInsn(RETURN);
cw.visitEnd();
byte[] carray = cw.toByteArray();
// for debugging
// write((new File("X.class")).toPath(), carray, CREATE, TRUNCATE_EXISTING);
// verify using javap/classfile reader
ClassFile cf = ClassFile.read(new ByteArrayInputStream(carray));
int mcount = checkMethod(cf, "foo");
if (mcount < 1) {
throw new RuntimeException("unexpected method count, expected 1" + "but got " + mcount);
}
}
Aggregations