String signature, String[] exceptions) { if (cv != null) { return cv.visitMethod(access, name, desc, signature, exceptions);
@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; }
/** * 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); } }
public static MethodVisitor visitMethod(ClassVisitor cv,MethodNode m){ return cv.visitMethod(m.access, m.name, m.desc, m.signature, Collections2.toStringArray(m.exceptions)); }
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodNode mn = ASM.getMethod(cn, name, desc); if(!methodBodyOnly && ASM.isStaticInit(mn)) { visitStaticInit = true; MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); return new ClinitMethodVisitor(mv, access, name, desc); } if(isMonitored(mn)) { MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); return new MonitoredMethodVisitor(type, mn, mv , access, name, desc); } return super.visitMethod(access, name, desc, signature, exceptions); }
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodNode method = ASM.getMethod(cn, name, desc); MethodVisitor mv; for(ModelTransformer transformer : transformers){ if((mv = transformer.transform(cn, cw, method)) != null){ return mv; } } return super.visitMethod(access, name, desc, signature, exceptions); } }
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodNode mn = ASM.getMethod(cn, name, desc); if(ASM.isStaticInit(mn)) { visitStaticInit = true; MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); return new ClinitMethodVisitor(mv, access, name, desc); } AopMethod am = isIntercepted(mn); if(null != am) { String newName = name + "$aop"; visitInterceptedMethod(am, newName); return super.visitMethod(access, newName, desc, signature, exceptions); }else{ return super.visitMethod(access, name, desc, signature, exceptions); } }
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodNode mn = ASM.getMethod(cn, name, desc); AnnotationNode a = ASM.getAnnotation(mn, Transactional.class); if(null != a) { log.trace(" #transactional method : {}", name); MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); return new TxMethodVisitor(a, mv , access, name, desc); } return super.visitMethod(access, name, desc, signature, exceptions); }
@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); }
@Override public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) { if (computeSVUID) { if ("<clinit>".equals(name)) { hasStaticInitializer = true; } /* * Remembers non private constructors and methods for SVUID * computation For constructor and method modifiers, only the * ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, * ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT and ACC_STRICT flags * are used. */ int mods = access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNCHRONIZED | Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_STRICT); // all non private methods if ((access & Opcodes.ACC_PRIVATE) == 0) { if ("<init>".equals(name)) { svuidConstructors.add(new Item(name, mods, desc)); } else if (!"<clinit>".equals(name)) { svuidMethods.add(new Item(name, mods, desc)); } } } return super.visitMethod(access, name, desc, signature, exceptions); }
/** * Creates a new {@link GeneratorAdapter}. <i>Subclasses must not use this * constructor</i>. Instead, they must use the * {@link #GeneratorAdapter(int, MethodVisitor, int, String, String)} * version. * * @param access * access flags of the adapted method. * @param method * the adapted method. * @param signature * the signature of the adapted method (may be <tt>null</tt>). * @param exceptions * the exceptions thrown by the adapted method (may be * <tt>null</tt>). * @param cv * the class visitor to which this adapter delegates calls. */ public GeneratorAdapter(final int access, final Method method, final String signature, final Type[] exceptions, final ClassVisitor cv) { this(access, method, cv .visitMethod(access, method.getName(), method.getDescriptor(), signature, getInternalNames(exceptions))); }
@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); }
MethodVisitor mv = classVisitor.visitMethod(context.access, context.name, context.desc, signature, exceptions); if (mv == null) {