public static XClass findImplementor(XClass clazz, String name, String signature, boolean isStatic) throws CheckedAnalysisException { XMethod m = clazz.findMethod(name, signature, isStatic); if (m != null) { return clazz; } return findSuperImplementor(clazz, name, signature, isStatic); }
public static @CheckForNull XMethod findMethod(ClassDescriptor classDescriptor, String methodName, String methodSig, boolean isStatic) { try { return getXClass(classDescriptor).findMethod(methodName, methodSig, isStatic); } catch (CheckedAnalysisException e) { return null; } }
/** * Find a method in given class. * * @param classDesc * the class descriptor * @param methodName * the name of the method * @param methodSig * the signature of the method * @param isStatic * are we looking for a static method? * @return the JavaClassAndMethod, or null if no such method exists in the * class */ public static @CheckForNull XMethod findMethod(ClassDescriptor classDesc, String methodName, String methodSig, boolean isStatic) { if (DEBUG_METHOD_LOOKUP) { System.out.println("Check " + classDesc.getClassName()); } try { XClass xClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, classDesc); return xClass.findMethod(methodName, methodSig, isStatic); } catch (CheckedAnalysisException e) { AnalysisContext.logError("Error looking for " + classDesc + "." + methodName + methodSig, e); return null; } }
static @Nonnull XMethod getInvokedMethod(XClass xClass, String name, String sig, boolean isStatic) throws CheckedAnalysisException { IAnalysisCache cache = Global.getAnalysisCache(); while (true) { XMethod result = xClass.findMethod(name, sig, isStatic); if (result != null) { return result; } if (isStatic) { throw new CheckedAnalysisException(); } ClassDescriptor superclassDescriptor = xClass.getSuperclassDescriptor(); if (superclassDescriptor == null) { throw new CheckedAnalysisException(); } xClass = cache.getClassAnalysis(XClass.class, superclassDescriptor); } }
@Override public boolean visitClass(ClassDescriptor classDescriptor, XClass xclass) { assert xclass != null; String methodSignature = xmethod.getSignature(); XMethod bridgedFrom = xmethod.bridgeFrom(); // See if this class has an overridden method XMethod xm = xclass.findMethod(xmethod.getName(), methodSignature, false); if (xm == null && bridgedFrom != null && !classDescriptor.equals(xmethod.getClassDescriptor())) { methodSignature = bridgedFrom.getSignature(); xm = xclass.findMethod(xmethod.getName(), methodSignature, false); } if (xm != null) { return visitOverriddenMethod(xm) || bridgedFrom != null; } else { // Even though this particular class doesn't contain the method // we're // looking for, a superclass might, so we need to keep going. return true; } }
@Override public MethodVisitor visitMethod(int methodAccess, String methodName, String desc, String methodSignature, String[] exceptions) { if ((methodAccess & ACC_STATIC) != 0) { // skip static methods return null; } final XMethod xmethod = xclass.findMethod(methodName, desc, false); if (xmethod == null) { // unable to continue the analysis bugReporter.reportSkippedAnalysis(new MethodDescriptor(xclass.getClassDescriptor().getClassName(), methodName, desc, false)); return null; } return new DetectorNode(methodAccess, methodName, desc, methodSignature, exceptions, xmethod); }
return Util.emptyOrNonnullSingleton(getXClass(objectDescriptor).findMethod(methodName, methodSig, false)); } catch (CheckedAnalysisException e) { return Collections.<XMethod> emptySet();
XMethod whenMethod = xclass.findMethod("when", "()Ljavax/annotation/meta/When;", false); if (whenMethod == null) { isStrict1 = true;
private boolean isCalledDirectlyOrIndirectly(@CheckForNull ClassDescriptor clazzDescriptor, XMethod m) throws CheckedAnalysisException { if (clazzDescriptor == null) { return false; } IAnalysisCache analysisCache = Global.getAnalysisCache(); XClass clazz = analysisCache.getClassAnalysis(XClass.class, clazzDescriptor); XMethod m2 = clazz.findMethod(m.getName(), m.getSignature(), m.isStatic()); if (m2 != null && isCalled(m2)) { return true; } if (isCalledDirectlyOrIndirectly(clazz.getSuperclassDescriptor(), m)) { return true; } for (ClassDescriptor i : clazz.getInterfaceDescriptorList()) { if (isCalledDirectlyOrIndirectly(i, m)) { return true; } } return false; }
boolean done = false; while (!done && (superClass = hierarchy.next()) != null) { XMethod method = superClass.findMethod(name, desc, false); if (method != null) { done = checkMethod(method);
int priority = NORMAL_PRIORITY; if ("wait".equals(methodName)) { m = c.findMethod("await", "()V", false); priority = HIGH_PRIORITY; } else if ("notify".equals(methodName)) { m = c.findMethod("signal", "()V", false); if (m == null) { m = c.findMethod("countDown", "()V", false); m = c.findMethod("signalAll", "()V", false); if (m == null) { m = c.findMethod("countDown", "()V", false);
if (xSub != null && xSub.findMethod("readResolve", "()Ljava/lang/Object;", false) == null && xSub.findMethod("writeReplace", "()Ljava/lang/Object;", false) == null) { bug.addClass(subclass).describe(ClassAnnotation.SUBCLASS_ROLE); nasty = true;
public static UsagesRequiringNonNullValues getAnalysis(ClassContext classContext, Method method) { XMethod thisMethod = classContext.getXClass().findMethod(method.getName(), method.getSignature(), method.isStatic()); if (DEBUG) { System.out.println(thisMethod);
inheritedEqualsFromAbstractClass = we.isAbstract(); whereEqual = we.getClassDescriptor().getDottedClassName(); inheritedEquals = we.findMethod("equals", "(Ljava/lang/Object;)Z", false); if (inheritedEquals != null) { inheritedEqualsIsFinal = inheritedEquals.isFinal(); } else { whereHashCode = wh.getClassDescriptor().getDottedClassName(); XMethod m = wh.findMethod("hashCode", "()I", false); if (m != null && m.isFinal()) { inheritedHashCodeIsFinal = true;
public static @CheckForNull XMethod findMethod(ClassDescriptor classDescriptor, String methodName, String methodSig, boolean isStatic) { try { return getXClass(classDescriptor).findMethod(methodName, methodSig, isStatic); } catch (CheckedAnalysisException e) { return null; } }
public static XClass findImplementor(XClass clazz, String name, String signature, boolean isStatic) throws CheckedAnalysisException { XMethod m = clazz.findMethod(name, signature, isStatic); if (m != null) { return clazz; } return findSuperImplementor(clazz, name, signature, isStatic); }
static @Nonnull XMethod getInvokedMethod(XClass xClass, String name, String sig, boolean isStatic) throws CheckedAnalysisException { IAnalysisCache cache = Global.getAnalysisCache(); while (true) { XMethod result = xClass.findMethod(name, sig, isStatic); if (result != null) { return result; } if (isStatic) { throw new CheckedAnalysisException(); } ClassDescriptor superclassDescriptor = xClass.getSuperclassDescriptor(); if (superclassDescriptor == null) { throw new CheckedAnalysisException(); } xClass = cache.getClassAnalysis(XClass.class, superclassDescriptor); } }
@Override public boolean visitClass(ClassDescriptor classDescriptor, XClass xclass) { assert xclass != null; String methodSignature = xmethod.getSignature(); XMethod bridgedFrom = xmethod.bridgeFrom(); // See if this class has an overridden method XMethod xm = xclass.findMethod(xmethod.getName(), methodSignature, false); if (xm == null && bridgedFrom != null && !classDescriptor.equals(xmethod.getClassDescriptor())) { methodSignature = bridgedFrom.getSignature(); xm = xclass.findMethod(xmethod.getName(), methodSignature, false); } if (xm != null) { return visitOverriddenMethod(xm) || bridgedFrom != null; } else { // Even though this particular class doesn't contain the method // we're // looking for, a superclass might, so we need to keep going. return true; } }
@Override public MethodVisitor visitMethod(int methodAccess, String methodName, String desc, String methodSignature, String[] exceptions) { if ((methodAccess & ACC_STATIC) != 0) { // skip static methods return null; } final XMethod xmethod = xclass.findMethod(methodName, desc, false); if (xmethod == null) { // unable to continue the analysis bugReporter.reportSkippedAnalysis(new MethodDescriptor(xclass.getClassDescriptor().getClassName(), methodName, desc, false)); return null; } return new DetectorNode(methodAccess, methodName, desc, methodSignature, exceptions, xmethod); }
private boolean isCalledDirectlyOrIndirectly(@CheckForNull ClassDescriptor clazzDescriptor, XMethod m) throws CheckedAnalysisException { if (clazzDescriptor == null) { return false; } IAnalysisCache analysisCache = Global.getAnalysisCache(); XClass clazz = analysisCache.getClassAnalysis(XClass.class, clazzDescriptor); XMethod m2 = clazz.findMethod(m.getName(), m.getSignature(), m.isStatic()); if (m2 != null && isCalled(m2)) { return true; } if (isCalledDirectlyOrIndirectly(clazz.getSuperclassDescriptor(), m)) { return true; } for (ClassDescriptor i : clazz.getInterfaceDescriptorList()) { if (isCalledDirectlyOrIndirectly(i, m)) { return true; } } return false; }