@Override public int compareTo(ComparableMethod o) { return FieldOrMethodDescriptor.compareTo(this, (MethodDescriptor)o); }
@Override public String toString() { return (isStatic ? "static " : "") + getClassDescriptor().getDottedClassName() + "." + name + signature; }
public FieldOrMethodDescriptor(@SlashedClassName String slashedClassName, String name, String signature, boolean isStatic) { assert slashedClassName.indexOf('.') == -1 : "class name not in VM format: " + slashedClassName; this.slashedClassName = slashedClassName; this.name = name; this.signature = signature; this.isStatic = isStatic; this.nameSigHashCode = getNameSigHashCode(this.name, this.signature); }
private void check(XMethod xmethod, ClassDescriptor annotation, boolean expectWarnings, int priority) { AnnotationValue expect = xmethod.getAnnotation(annotation); if (expect == null) { return; } if (DEBUG) { System.out.println("*** Found " + annotation + " annotation on " + xmethod); } FieldOrMethodDescriptor descriptor = xmethod.getMethodDescriptor(); Collection<BugInstance> warnings = warningsByMethod.get(descriptor); check(expect, descriptor, warnings, expectWarnings, priority, descriptor.getClassDescriptor()); }
@Override public int compareTo(ComparableField o) { return FieldOrMethodDescriptor.compareTo(this, (FieldDescriptor)o); }
@Override public XMethod findMethod(String methodName, String methodSig, boolean isStatic) { int hash = FieldOrMethodDescriptor.getNameSigHashCode(methodName, methodSig); for (MethodInfo mInfo : xMethods) { if (mInfo.getNameSigHashCode() == hash && mInfo.getName().equals(methodName) && mInfo.getSignature().equals(methodSig) && mInfo.isStatic() == isStatic) { return mInfo; } } return null; }
private void check(XField xfield, ClassDescriptor annotation, boolean expectWarnings, int priority) { AnnotationValue expect = xfield.getAnnotation(annotation); if (expect == null) { return; } if (DEBUG) { System.out.println("*** Found " + annotation + " annotation on " + xfield); } FieldOrMethodDescriptor descriptor = xfield.getFieldDescriptor(); Collection<BugInstance> warnings = warningsByField.get(descriptor); check(expect, descriptor, warnings, expectWarnings, priority, descriptor.getClassDescriptor()); }
@Override public int compareTo(ComparableMethod rhs) { if (rhs instanceof MethodDescriptor) { return FieldOrMethodDescriptor.compareTo(this, (MethodDescriptor) rhs); } if (rhs instanceof XMethod) { return XFactory.compare((XMethod) this, (XMethod) rhs); } throw new ClassCastException("Can't compare a " + this.getClass().getName() + " to a " + rhs.getClass().getName()); }
/** * Returns true if given constant pool probably has a reference to any of supplied methods * Useful to exclude from analysis uninteresting classes * @param cp constant pool * @param methods methods collection * @return true if method is found */ public static boolean hasInterestingMethod(ConstantPool cp, Collection<MethodDescriptor> methods) { for(Constant c : cp.getConstantPool()) { if(c instanceof ConstantMethodref || c instanceof ConstantInterfaceMethodref) { ConstantCP desc = (ConstantCP)c; ConstantNameAndType nameAndType = (ConstantNameAndType) cp.getConstant(desc.getNameAndTypeIndex()); String className = cp.getConstantString(desc.getClassIndex(), Const.CONSTANT_Class); String name = ((ConstantUtf8)cp.getConstant(nameAndType.getNameIndex())).getBytes(); String signature = ((ConstantUtf8)cp.getConstant(nameAndType.getSignatureIndex())).getBytes(); // We don't know whether method is static thus cannot use equals int hash = FieldOrMethodDescriptor.getNameSigHashCode(name, signature); for(MethodDescriptor method : methods) { if (method.getNameSigHashCode() == hash && (method.getSlashedClassName().isEmpty() || method.getSlashedClassName().equals(className)) && method.getName().equals(name) && method.getSignature().equals(signature)) { return true; } } } } return false; }
protected int compareTo(FieldOrMethodName o) { int cmp; cmp = this.getClassDescriptor().compareTo(o.getClassDescriptor()); if (cmp != 0) { return cmp; } cmp = this.name.compareTo(o.getName()); if (cmp != 0) { return cmp; } cmp = this.signature.compareTo(o.getSignature()); if (cmp != 0) { return cmp; } return (this.isStatic ? 1 : 0) - (o.isStatic() ? 1 : 0); }
@Override public int compareTo(ComparableField rhs) { if (rhs instanceof FieldDescriptor) { return FieldOrMethodDescriptor.compareTo(this, (FieldDescriptor) rhs); } if (rhs instanceof XField) { return XFactory.compare((XField) this, (XField) rhs); } throw new ClassCastException("Can't compare a " + this.getClass().getName() + " to a " + rhs.getClass().getName()); }
@Override public XField findField(String name, String signature, boolean isStatic) { int hash = FieldOrMethodDescriptor.getNameSigHashCode(name, signature); for (FieldInfo fInfo : xFields) { if (fInfo.getNameSigHashCode() == hash && fInfo.getName().equals(name) && fInfo.getSignature().equals(signature)
sortedMethodSet.addAll(propertyMap.keySet()); for (KeyType key : sortedMethodSet) { if (AnalysisContext.currentAnalysisContext().isApplicationClass(key.getClassDescriptor())) {
@Override public int compareTo(ComparableMethod o) { return FieldOrMethodDescriptor.compareTo(this, (MethodDescriptor)o); }
@Override public XMethod findMethod(String methodName, String methodSig, boolean isStatic) { int hash = FieldOrMethodDescriptor.getNameSigHashCode(methodName, methodSig); for (MethodInfo mInfo : xMethods) { if (mInfo.getNameSigHashCode() == hash && mInfo.getName().equals(methodName) && mInfo.getSignature().equals(methodSig) && mInfo.isStatic() == isStatic) { return mInfo; } } return null; }
@Override public String toString() { return (isStatic ? "static " : "") + getClassDescriptor().getDottedClassName() + "." + name + signature; }
@Override public int compareTo(ComparableField o) { return FieldOrMethodDescriptor.compareTo(this, (FieldDescriptor)o); }
public FieldOrMethodDescriptor(@SlashedClassName String slashedClassName, String name, String signature, boolean isStatic) { assert slashedClassName.indexOf('.') == -1 : "class name not in VM format: " + slashedClassName; this.slashedClassName = DescriptorFactory.canonicalizeString(slashedClassName); this.name = DescriptorFactory.canonicalizeString(name); this.signature = DescriptorFactory.canonicalizeString(signature); this.isStatic = isStatic; this.nameSigHashCode = getNameSigHashCode(this.name, this.signature); }
private void check(XMethod xmethod, ClassDescriptor annotation, boolean expectWarnings, int priority) { AnnotationValue expect = xmethod.getAnnotation(annotation); if (expect == null) { return; } if (DEBUG) { System.out.println("*** Found " + annotation + " annotation on " + xmethod); } FieldOrMethodDescriptor descriptor = xmethod.getMethodDescriptor(); Collection<BugInstance> warnings = warningsByMethod.get(descriptor); check(expect, descriptor, warnings, expectWarnings, priority, descriptor.getClassDescriptor()); }
@Override public int compareTo(ComparableField rhs) { if (rhs instanceof FieldDescriptor) { return FieldOrMethodDescriptor.compareTo(this, (FieldDescriptor) rhs); } if (rhs instanceof XField) { return XFactory.compare((XField) this, (XField) rhs); } throw new ClassCastException("Can't compare a " + this.getClass().getName() + " to a " + rhs.getClass().getName()); }