protected static boolean isMonitored(MethodNode mn) { if(ASM.isAnnotationPresent(mn, Monitored.class)) { return true; } if(ASM.isConstructor(mn) || ASM.isStaticInit(mn)) { return false; } if(Modifier.isStatic(mn.access)) { return false; } String name = mn.name; if(name.startsWith("get") && name.length() > 3 && !ASM.hasArgument(mn)) { return false; } if(name.startsWith("is") && name.length() > 2 && !ASM.hasArgument(mn)) { return false; } if(name.startsWith("set") && name.length() > 3 && ASM.getArgumentSize(mn) == 1) { return false; } return true; }
@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 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); } }