public HierarchyIterator(@Nonnull XClass xclass) { interfacesToVisit = new LinkedList<>(Arrays.asList(xclass.getInterfaceDescriptorList())); visited = new HashSet<>(); superclass = getClassInfo(xclass.getSuperclassDescriptor()); }
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); } }
public @CheckForNull XField getXFieldOperand() { if (getReferencedXClass() != null && referencedXField == null) { referencedXField = getReferencedXClass().findField(nameConstantOperand, sigConstantOperand, opcode == Const.GETSTATIC || opcode == Const.PUTSTATIC); } return referencedXField; }
private void check(XClass xclass, ClassDescriptor annotation, boolean expectWarnings, int priority) { AnnotationValue expect = xclass.getAnnotation(annotation); if (expect == null) { return; } if (DEBUG) { System.out.println("*** Found " + annotation + " annotation on " + xclass); } ClassDescriptor descriptor = xclass.getClassDescriptor(); Collection<BugInstance> warnings = warningsByClass.get(descriptor); check(expect, descriptor, warnings, expectWarnings, priority, descriptor); }
public static @CheckForNull XMethod findInvocationLeastUpperBound(XClass jClass, String methodName, String methodSig, boolean invokeStatic, boolean invokeInterface) { XMethod result = findMethod(jClass.getClassDescriptor(), methodName, methodSig, invokeStatic); if (result != null) { return result; } ClassDescriptor sClass = jClass.getSuperclassDescriptor(); if (sClass != null) { result = findInvocationLeastUpperBound(sClass, methodName, methodSig, invokeStatic, invokeInterface); if (result != null) { return result; } } for (ClassDescriptor i : jClass.getInterfaceDescriptorList()) { result = findInvocationLeastUpperBound(i, methodName, methodSig, invokeStatic, invokeInterface); if (result != null) { return result; } } return null; }
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; }
private boolean isStaticOnlyClass(XClass xClass) { if (xClass.getInterfaceDescriptorList().length > 0) { return false; ClassDescriptor superclassDescriptor = xClass.getSuperclassDescriptor(); if (superclassDescriptor == null) { return false; List<? extends XMethod> methods = xClass.getXMethods(); for (XMethod m : methods) { List<? extends XField> fields = xClass.getXFields(); for (XField f : fields) { if (f.isStatic()) {
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); }
return Priorities.IGNORE_PRIORITY; ClassDescriptor superclassDescriptor = xClass.getSuperclassDescriptor(); if (superclassDescriptor != null) { @SlashedClassName for (XField f : xClass.getXFields()) { if (!f.isStatic()) { if (!f.isFinal() && !f.isSynthetic()) { if (!hasMutableField && !xClass.isInterface() && !xClass.isAbstract()) { return Priorities.LOW_PRIORITY;
public static XClass findSuperImplementor(XClass clazz, String name, String signature, boolean isStatic) throws CheckedAnalysisException { ClassDescriptor superclassDescriptor = clazz.getSuperclassDescriptor(); if (superclassDescriptor == null) { return clazz; } return findImplementor(getXClass(superclassDescriptor), name, signature, isStatic); }
private static void findSuperMethods(@CheckForNull ClassDescriptor c, XMethod m, Set<XMethod> accumulator) { if (c == null) { return; } try { XClass xc = getXClass(c); XMethod xm = xc.findMatchingMethod(m.getMethodDescriptor()); if (xm != null && !accumulator.add(xm)) { return; } findSuperMethods(xc.getSuperclassDescriptor(), m, accumulator); for (ClassDescriptor i : xc.getInterfaceDescriptorList()) { findSuperMethods(i, m, accumulator); } if (!accumulator.add(m)) { return; } } catch (CheckedAnalysisException e) { AnalysisContext.logError("Error finding super methods for " + m, e); } }
XClass classNameAndInfo = Global.getAnalysisCache().getClassAnalysis(XClass.class, classDesc); ClassDescriptor superclassDescriptor = classNameAndInfo.getSuperclassDescriptor(); if (superclassDescriptor != null && addedToWorkList.add(superclassDescriptor)) { workList.addLast(superclassDescriptor); for (ClassDescriptor ifaceDesc : classNameAndInfo.getInterfaceDescriptorList()) { if (addedToWorkList.add(ifaceDesc)) { workList.addLast(ifaceDesc); ClassDescriptor enclosingClass = classNameAndInfo.getImmediateEnclosingClass(); if (enclosingClass != null && addedToWorkList.add(enclosingClass)) { workList.addLast(enclosingClass);
superClassHasReadObject = false; superClassImplementsSerializable = isSerializable && !implementsSerializableDirectly; ClassDescriptor superclassDescriptor = getXClass().getSuperclassDescriptor(); if (superclassDescriptor != null) { try { .currentAnalysisContext() .getSubtypes2() .isSubtype(superXClass.getClassDescriptor(), DescriptorFactory.createClassDescriptor(java.io.Serializable.class)); superClassHasVoidConstructor = false; for (XMethod m : superXClass.getXMethods()) { if (Const.CONSTRUCTOR_NAME.equals(m.getName()) && "()V".equals(m.getSignature()) && !m.isPrivate()) { superClassHasVoidConstructor = true;
String name = fieldClass.getClassDescriptor().getClassName(); if (name.startsWith("java/awt") || name.startsWith("javax/swing")) { return; break; fieldType = fieldClass.getSuperclassDescriptor(); priority = LOW_PRIORITY; if (classContext.getXClass().usesConcurrency()) { priority--;
XMethod whenMethod = xclass.findMethod("when", "()Ljavax/annotation/meta/When;", false); if (whenMethod == null) { isStrict1 = true; for (XMethod xmethod : xclass.getXMethods()) { if ("value".equals(xmethod.getName()) && xmethod.getSignature().startsWith("()")) { isExhaustive1 = xmethod.getAnnotation(EXHAUSTIVE_ANNOTATION) != null;
whereEqual = "java.lang.Object"; } else { inheritedEqualsFromAbstractClass = we.isAbstract(); whereEqual = we.getClassDescriptor().getDottedClassName(); inheritedEquals = we.findMethod("equals", "(Ljava/lang/Object;)Z", false); if (inheritedEquals != null) { inheritedEqualsIsFinal = inheritedEquals.isFinal(); whereHashCode = "java.lang.Object"; } else { whereHashCode = wh.getClassDescriptor().getDottedClassName(); XMethod m = wh.findMethod("hashCode", "()I", false); if (m != null && m.isFinal()) { inheritedHashCodeIsFinal = true;
public static @CheckForNull XMethod findFirstSuperMethod(XMethod m) { try { @CheckForNull ClassDescriptor c = m.getClassDescriptor(); XClass xc = getXClass(c); c = xc.getSuperclassDescriptor(); while (c != null) { xc = getXClass(c); XMethod xm = xc.findMatchingMethod(m.getMethodDescriptor()); if (xm != null) { return xm; } c = xc.getSuperclassDescriptor(); } } catch (CheckedAnalysisException e) { AnalysisContext.logError("Error finding super methods for " + m, e); } return null; }
@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); }
ClassDescriptor superclassDescriptor = xClass.getSuperclassDescriptor(); if (superclassDescriptor != null && MUTABLE_COLLECTION_CLASSES.contains(superclassDescriptor.getClassName())) { mutableCollectionJustCreated = true; for (XMethod xMethod : xClass.getXMethods()) { if (xMethod != null && !Const.CONSTRUCTOR_NAME.equals(xMethod.getName()) && !Const.STATIC_INITIALIZER_NAME.equals(xMethod.getName())) { mutableCollectionJustCreated = false;
ClassDescriptor s = c.getSuperclassDescriptor(); if (s == null || "java/lang/Object".equals(s.getClassName())) { break; for (XField fld : c.getXFields()) { if (!fld.isStatic() && (fld.isPublic() || fld.isProtected())) { fieldName = fld.getName();