/** * Add a method annotation. If this is the first method annotation added, it * becomes the primary method annotation. * * @param className * name of the class containing the method * @param methodName * name of the method * @param methodSig * type signature of the method * @param isStatic * true if the method is static, false otherwise * @return this object */ @Nonnull public BugInstance addMethod(String className, String methodName, String methodSig, boolean isStatic) { addMethod(MethodAnnotation.fromForeignMethod(className, methodName, methodSig, isStatic)); return this; }
/** * Create a MethodAnnotation from a method that is not directly accessible. * We will use the repository to try to find its class in order to populate * the information as fully as possible. * * @param className * class containing called method * @param methodName * name of called method * @param methodSig * signature of called method * @param isStatic * true if called method is static * @return the MethodAnnotation for the called method */ public static MethodAnnotation fromCalledMethod(String className, String methodName, String methodSig, boolean isStatic) { MethodAnnotation methodAnnotation = fromForeignMethod(className, methodName, methodSig, isStatic); methodAnnotation.setDescription("METHOD_CALLED"); return methodAnnotation; }
/** * Add a method annotation. If this is the first method annotation added, it * becomes the primary method annotation. * * @param className * name of the class containing the method * @param methodName * name of the method * @param methodSig * type signature of the method * @param accessFlags * accessFlags for the method * @return this object */ @Nonnull public BugInstance addMethod(@SlashedClassName String className, String methodName, String methodSig, int accessFlags) { addMethod(MethodAnnotation.fromForeignMethod(className, methodName, methodSig, accessFlags)); return this; }
@Override public void visitMethodInsn(int opcode, String owner, String invokedName, String invokedDesc, boolean itf) { if (prevPC + 1 == getPC() && prevOpcode == I2D && opcode == INVOKESTATIC && "java/lang/Math".equals(owner) && "ceil".equals(invokedName) && "(D)D".equals(invokedDesc)) { BugInstance bug0 = new BugInstance(TestASM.this, "ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL", NORMAL_PRIORITY); MethodAnnotation methodAnnotation = MethodAnnotation.fromForeignMethod(TestASM.this.name, name, desc, access); bug0.addClass(TestASM.this).addMethod(methodAnnotation); bugReporter.reportBug(bug0); } } };
/** * Create a MethodAnnotation from an XMethod. * * @param xmethod * the XMethod * @return the MethodAnnotation */ public static MethodAnnotation fromXMethod(XMethod xmethod) { return fromForeignMethod(xmethod.getClassName(), xmethod.getName(), xmethod.getSignature(), xmethod.isStatic()); }
/** * Create a MethodAnnotation from a MethodDescriptor. * * @param methodDescriptor * the MethodDescriptor * @return the MethodAnnotation */ public static MethodAnnotation fromMethodDescriptor(MethodDescriptor methodDescriptor) { return fromForeignMethod(methodDescriptor.getSlashedClassName(), methodDescriptor.getName(), methodDescriptor.getSignature(), methodDescriptor.isStatic()); }
/** * Create a MethodAnnotation from a method that is not directly accessible. * We will use the repository to try to find its class in order to populate * the information as fully as possible. * * @param className * class containing called method * @param methodName * name of called method * @param methodSig * signature of called method * @param isStatic * true if called method is static * @return the MethodAnnotation for the called method */ public static MethodAnnotation fromCalledMethod(String className, String methodName, String methodSig, boolean isStatic) { MethodAnnotation methodAnnotation = fromForeignMethod(className, methodName, methodSig, isStatic); methodAnnotation.setDescription("METHOD_CALLED"); return methodAnnotation; }
/** * Add a method annotation. If this is the first method annotation added, it * becomes the primary method annotation. * * @param className * name of the class containing the method * @param methodName * name of the method * @param methodSig * type signature of the method * @param isStatic * true if the method is static, false otherwise * @return this object */ @Nonnull public BugInstance addMethod(String className, String methodName, String methodSig, boolean isStatic) { addMethod(MethodAnnotation.fromForeignMethod(className, methodName, methodSig, isStatic)); return this; }
/** * Add a method annotation. If this is the first method annotation added, it * becomes the primary method annotation. * * @param className * name of the class containing the method * @param methodName * name of the method * @param methodSig * type signature of the method * @param accessFlags * accessFlags for the method * @return this object */ @Nonnull public BugInstance addMethod(@SlashedClassName String className, String methodName, String methodSig, int accessFlags) { addMethod(MethodAnnotation.fromForeignMethod(className, methodName, methodSig, accessFlags)); return this; }
@Override public void visitMethodInsn(int opcode, String owner, String invokedName, String invokedDesc, boolean itf) { if (prevPC + 1 == getPC() && prevOpcode == I2D && opcode == INVOKESTATIC && "java/lang/Math".equals(owner) && "ceil".equals(invokedName) && "(D)D".equals(invokedDesc)) { BugInstance bug0 = new BugInstance(TestASM.this, "ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL", NORMAL_PRIORITY); MethodAnnotation methodAnnotation = MethodAnnotation.fromForeignMethod(TestASM.this.name, name, desc, access); bug0.addClass(TestASM.this).addMethod(methodAnnotation); bugReporter.reportBug(bug0); } } };
/** * Create a MethodAnnotation from a MethodDescriptor. * * @param methodDescriptor * the MethodDescriptor * @return the MethodAnnotation */ public static MethodAnnotation fromMethodDescriptor(MethodDescriptor methodDescriptor) { return fromForeignMethod(methodDescriptor.getSlashedClassName(), methodDescriptor.getName(), methodDescriptor.getSignature(), methodDescriptor.isStatic()); }
/** * Create a MethodAnnotation from an XMethod. * * @param xmethod * the XMethod * @return the MethodAnnotation */ public static MethodAnnotation fromXMethod(XMethod xmethod) { return fromForeignMethod(xmethod.getClassName(), xmethod.getName(), xmethod.getSignature(), xmethod.isStatic()); }