public String formatMessage(AsmMethod asmMethod) { if (asmMethod.isConstructor()) { return "Constructor '" + getShortClassName(asmMethod.getParent()) + "(...)' is deprecated."; } else { return "Method '" + getShortClassName(asmMethod.getParent()) + "." + asmMethod.getName() + "(...)' is deprecated."; } }
private boolean isCallToNonStaticInternalMethod(AsmEdge edge) { return edge.getTargetAsmClass() == getParent() && edge.getUsage() == SourceCodeEdgeUsage.CALLS_METHOD && !((AsmMethod) edge.getTo()).isStatic(); }
private boolean isCallToNonStaticInternalField(AsmEdge edge) { return edge.getTargetAsmClass() == getParent() && edge.getUsage() == SourceCodeEdgeUsage.CALLS_FIELD && !((AsmField) edge.getTo()).isStatic(); }
private boolean isCallToNonStaticInternalMethod(AsmEdge edge) { return edge.getTargetAsmClass() == getParent() && edge.getUsage() == SourceCodeEdgeUsage.CALLS_METHOD && !((AsmMethod) edge.getTo()).isStatic(); }
private boolean isCallToNonStaticInternalField(AsmEdge edge) { return edge.getTargetAsmClass() == getParent() && edge.getUsage() == SourceCodeEdgeUsage.CALLS_FIELD && !((AsmField) edge.getTo()).isStatic(); }
protected final int getMethodLineNumber(AsmMethod asmMethod) { MethodSignature methodSignature = MethodSignatureScanner.scan(asmMethod.getGenericKey()); AsmClass asmClass = asmMethod.getParent(); Integer result = javaResourceLocator.getMethodStartLine(asmClass.getInternalName() + "#" + MethodSignaturePrinter.print(methodSignature)); if (result != null) { return result; } return -1; }
@Override public void visitEdge(AsmEdge edge) { if (edge.getTo() instanceof AsmMethod) { AsmMethod targetMethod = (AsmMethod) edge.getTo(); AsmClass targetClass = targetMethod.getParent(); if ("java/io/File".equals(targetClass.getInternalName()) && "deleteOnExit()V".equals(targetMethod.getKey())) { SourceFile sourceFile = getSourceFile(asmClass); CheckMessage message = new CheckMessage(this, "Do not use method 'File#deleteOnExit()'."); message.setLine(edge.getSourceLineNumber()); sourceFile.log(message); } } }
public void process(AsmMethod method) { if (!method.isBodyLoaded() && method.isUsed()) { AsmMethod implementation = findImplementation(method.getParent(), method.getKey()); if (implementation != null) { implementation.setUsed(true); method.linkTo(implementation); } } }
public void process(AsmMethod method) { if (!method.isBodyLoaded() && method.isUsed()) { AsmMethod implementation = findImplementation(method.getParent(), method.getKey()); if (implementation != null) { implementation.setUsed(true); method.linkTo(implementation); } } }
protected final int getMethodLineNumber(AsmMethod asmMethod) { MethodSignature methodSignature = MethodSignatureScanner.scan(asmMethod.getGenericKey()); AsmClass asmClass = asmMethod.getParent(); Integer result = context.getJavaResourceLocator().getMethodStartLine(asmClass.getInternalName() + "#" + MethodSignaturePrinter.print(methodSignature)); if (result != null) { return result; } return -1; }
@Override public MethodVisitor visitMethod(int access, String methodName, String description, String signature, String[] exceptions) { AsmMethod method = asmClass.getMethodOrCreateIt(methodName + description); if (isInheritedMethodSignature(method.getParent(), method.getKey())) { method.setInherited(true); } method.setSignature(signature); method.setBodyLoaded(true); method.setAccessFlags(access); method.clearOutogingEdges(); String[] internalNames = AsmSignature.extractInternalNames(description, signature); AsmClass[] asmClasses = internalNamesToAsmClasses(internalNames, DETAIL_LEVEL.NOTHING); method.addUsesOfClasses(asmClasses); AsmClass[] asmExceptionClasses = internalNamesToAsmClasses(exceptions, DETAIL_LEVEL.STRUCTURE); method.addUsesOfClasses(asmExceptionClasses); method.addThrowsOfClasses(asmExceptionClasses); if (level == DETAIL_LEVEL.STRUCTURE_AND_CALLS) { return new AsmMethodVisitor(method, asmClassProvider); } return null; }
@Override public MethodVisitor visitMethod(int access, String methodName, String description, String signature, String[] exceptions) { AsmMethod method = asmClass.getMethodOrCreateIt(methodName + description); if (isInheritedMethodSignature(method.getParent(), method.getKey())) { method.setInherited(true); } method.setSignature(signature); method.setBodyLoaded(true); method.setAccessFlags(access); method.clearOutogingEdges(); String[] internalNames = AsmSignature.extractInternalNames(description, signature); AsmClass[] asmClasses = internalNamesToAsmClasses(internalNames, DETAIL_LEVEL.NOTHING); method.addUsesOfClasses(asmClasses); AsmClass[] asmExceptionClasses = internalNamesToAsmClasses(exceptions, DETAIL_LEVEL.STRUCTURE); method.addUsesOfClasses(asmExceptionClasses); method.addThrowsOfClasses(asmExceptionClasses); if (level == DETAIL_LEVEL.STRUCTURE_AND_CALLS) { return new AsmMethodVisitor(method, asmClassProvider); } return null; }