Java 类org.objectweb.asm.MethodAdapter 实例源码

项目:annotation-tools    文件:ClassAnnotationSceneWriter.java   
/**
 * {@inheritDoc}
 * @see org.objectweb.asm.ClassAdapter#visitMethod(int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[])
 */
@Override
public MethodVisitor visitMethod(int access, String name, String desc,
    String signature, String[] exceptions) {
  ensureVisitSceneClassAnnotations();
  // MethodAnnotationSceneWriter ensures that the method visits all
  //  its annotations in the scene.
  // MethodAdapter is used here only for getting around an unsound
  //  "optimization" in ClassReader.
  return new MethodAdapter(new MethodAnnotationSceneWriter(name, desc,
          super.visitMethod(access, name, desc, signature, exceptions)));
}
项目:tascalate-javaflow    文件:MaybeContinuableClassVisitor.java   
@Override
public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) {
    if (isAnnotation) {
        return null;
    }

    boolean isSynthetic = (access & Opcodes.ACC_SYNTHETIC) != 0 ;
    if (isSynthetic) {
        boolean isPackagePrivate =  (access & (Opcodes.ACC_PRIVATE | Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED)) == 0 ;
        boolean isAccessor = isPackagePrivate && name.startsWith("access$") && (access & Opcodes.ACC_STATIC) != 0;
        boolean isBridge = (access & Opcodes.ACC_BRIDGE) != 0;
        if (isAccessor || isBridge) {
            return new MethodAdapter(NOP) {
                @Override
                public void visitMethodInsn(int opcode, String owner, String targetName, String targetDesc) {
                    if (selfclass.equals(owner)) {
                        normal2synthetic.put(targetName + targetDesc, name + desc);
                    }
                }
            };
        }
    }

    return new MethodAdapter(NOP) {

        private boolean methodContinuableAnnotationFound = false;

        @Override
        public AnnotationVisitor visitAnnotation(final String description, boolean visible) {
            if (!methodContinuableAnnotationFound) {
                methodContinuableAnnotationFound = environment.isContinuableAnnotation(description);
            }
            return null;
        }

        @Override 
        public void visitEnd() {
            if (methodContinuableAnnotationFound) {
                continuableMethods.add(name + desc);
            }
        }

    };
}