RememberedBug(BugInstance bug, FieldAnnotation maskingField, FieldAnnotation maskedField) { this.bug = bug; this.maskingField = XFactory.createXField(maskingField); this.maskedField = XFactory.createXField(maskedField); } }
/** * Convert to an XMethod. */ public XMethod toXMethod() { return XFactory.createXMethod(javaClass, method); }
/** * Set the current analysis context for this thread. * * @param analysisContext * the current analysis context for this thread */ public static void setCurrentAnalysisContext(AnalysisContext analysisContext) { currentAnalysisContext.set(analysisContext); if (Global.getAnalysisCache() != null) { currentXFactory.set(new XFactory()); } }
/** * @param className * @param methodName * @param methodSig * @param isStatic * @return the created XMethod */ public static XMethod createXMethodUsingSlashedClassName(@SlashedClassName String className, String methodName, String methodSig, boolean isStatic) { assertSlashedClassName(className); MethodDescriptor desc = DescriptorFactory.instance().getMethodDescriptor(className, methodName, methodSig, isStatic); return createXMethod(desc); }
private void addPropertiesForMethodContainingWarning(WarningPropertySet<WarningProperty> propertySet) { XMethod xMethod = XFactory.createXMethod(classContext.getJavaClass(), method); boolean uncallable = !AnalysisContext.currentXFactory().isCalledDirectlyOrIndirectly(xMethod) && xMethod.isPrivate(); if (uncallable) { propertySet.addProperty(GeneralWarningProperty.IN_UNCALLABLE_METHOD); } }
/** * @param className * @param methodName * @param methodSig * @param isStatic * @return the created XMethod */ public static XMethod createXMethod(@DottedClassName String className, String methodName, String methodSig, boolean isStatic) { assertDottedClassName(className); MethodDescriptor desc = DescriptorFactory.instance().getMethodDescriptor(ClassName.toSlashedClassName(className), methodName, methodSig, isStatic); return createXMethod(desc); }
@Nonnull public BugInstance lowerPriorityIfDeprecated() { MethodAnnotation m = getPrimaryMethod(); if (m != null && XFactory.createXMethod(m).isDeprecated()) { lowerPriority(); } FieldAnnotation f = getPrimaryField(); if (f != null && XFactory.createXField(f).isDeprecated()) { lowerPriority(); } return this; }
if (seen != Const.PUTFIELD && seen != Const.PUTSTATIC) { data.readFields.add(pendingGetField); } else if (XFactory.createReferencedXField(this).equals(pendingGetField) && (saState == 4 || seen == Const.PUTSTATIC)) { selfAssignment = true; } else { String fieldClass = (String) stack.getStackItem(2).getConstant(); if (fieldName != null && fieldSignature != null && fieldClass != null) { XField f = XFactory.createXField(fieldClass.replace('/', '.'), fieldName, ClassName.toSignature(fieldSignature), false); data.reflectiveFields.add(f); String fieldClass = (String) stack.getStackItem(1).getConstant(); if (fieldName != null && fieldClass != null) { XField f = XFactory.createXField(fieldClass.replace('/', '.'), fieldName, "I", false); data.reflectiveFields.add(f); String fieldClass = (String) stack.getStackItem(1).getConstant(); if (fieldName != null && fieldClass != null) { XField f = XFactory.createXField(fieldClass.replace('/', '.'), fieldName, "J", false); data.reflectiveFields.add(f); XField f = XFactory.createReferencedXField(this); data.staticFieldsReadInThisMethod.add(f); } else if (seen == Const.INVOKESTATIC) { seenInvokeStatic = true; } else if (seen == Const.PUTSTATIC && !getMethod().isStatic()) { XField f = XFactory.createReferencedXField(this); OpcodeStack.Item valuePut = getStack().getStackItem(0);
AnalysisContext currentAnalysisContext = AnalysisContext.currentAnalysisContext(); XFactory xFactory = AnalysisContext.currentXFactory(); for (XField f : AnalysisContext.currentXFactory().allFields()) { ClassDescriptor classDescriptor = f.getClassDescriptor(); if (currentAnalysisContext.isApplicationClass(classDescriptor) && !currentAnalysisContext.isTooBig(classDescriptor) && !xFactory.isReflectiveClass(classDescriptor)) { declaredFields.add(f);
public ReflectiveClasses(BugReporter bugReporter) { AnalysisContext.currentXFactory().addReflectiveClasses(DescriptorFactory.createClassDescriptor(java.lang.System.class)); }
@Override public void report() { emptyArray.removeAll(nonEmptyArray); for (XField f : emptyArray) { xFactory.addEmptyArrayField(f); } emptyArray.clear(); }
@Override public void report() { Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2(); for (XField f : AnalysisContext.currentXFactory().allFields()) { if (isVolatileArray(f) && subtypes2.isApplicationClass(f.getClassDescriptor())) { int priority = LOW_PRIORITY; if (initializationWrites.contains(f) && !otherWrites.contains(f)) { priority = NORMAL_PRIORITY; } bugReporter.reportBug(new BugInstance(this, "VO_VOLATILE_REFERENCE_TO_ARRAY", priority).addClass( f.getClassDescriptor()).addField(f)); } } }
Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2(); if (subtypes2.isApplicationClass(c)) { xFactory.addCalledMethod(getMethodDescriptorOperand());
if (!m.isStatic()) { XFactory xFactory = AnalysisContext.currentXFactory(); xFactory.addFunctionThatMightBeMistakenForProcedures(getMethodDescriptor()); if (inferredMethod != null) { inferredMethod.setPriority(priority);
@Override public void visitAnnotation(String annotationClass, Map<String, ElementValue> map, boolean runtimeVisible) { if (annotationClass.startsWith(NET_JCIP_ANNOTATIONS)) { annotationClass = annotationClass.substring(NET_JCIP_ANNOTATIONS.length()); } else if (annotationClass.startsWith(JSR305_CONCURRENT_ANNOTATIONS)) { annotationClass = annotationClass.substring(JSR305_CONCURRENT_ANNOTATIONS.length()); } else { return; } JCIPAnnotationDatabase annotationDatabase = AnalysisContext.currentAnalysisContext() .getJCIPAnnotationDatabase(); ElementValue value = map.get("value"); ClassMember member; if (visitingField()) { member = XFactory.createXField(this); } else if (visitingMethod()) { member = XFactory.createXMethod(this); } else { annotationDatabase.addEntryForClass(getDottedClassName(), annotationClass, value); return; } annotationDatabase.addEntryForClassMember(member, annotationClass, value); }
private void addPropertiesForMethodContainingWarning(WarningPropertySet<WarningProperty> propertySet) { XMethod xMethod = XFactory.createXMethod(classContext.getJavaClass(), method); boolean uncallable = !AnalysisContext.currentXFactory().isCalledDirectlyOrIndirectly(xMethod) && xMethod.isPrivate(); if (uncallable) { propertySet.addProperty(GeneralWarningProperty.IN_UNCALLABLE_METHOD); } }
/** * @param className * @param methodName * @param methodSig * @param isStatic * @return the created XMethod */ public static XMethod createXMethod(@DottedClassName String className, String methodName, String methodSig, boolean isStatic) { assertDottedClassName(className); MethodDescriptor desc = DescriptorFactory.instance().getMethodDescriptor(ClassName.toSlashedClassName(className), methodName, methodSig, isStatic); return createXMethod(desc); }
/** * @param className * @param methodName * @param methodSig * @param isStatic * @return the created XMethod */ public static XMethod createXMethodUsingSlashedClassName(@SlashedClassName String className, String methodName, String methodSig, boolean isStatic) { assertSlashedClassName(className); MethodDescriptor desc = DescriptorFactory.instance().getMethodDescriptor(className, methodName, methodSig, isStatic); return createXMethod(desc); }
AnalysisContext currentAnalysisContext = AnalysisContext.currentAnalysisContext(); XFactory xFactory = AnalysisContext.currentXFactory(); for (XField f : AnalysisContext.currentXFactory().allFields()) { ClassDescriptor classDescriptor = f.getClassDescriptor(); if (currentAnalysisContext.isApplicationClass(classDescriptor) && !currentAnalysisContext.isTooBig(classDescriptor) && !xFactory.isReflectiveClass(classDescriptor)) { declaredFields.add(f);
private void process(@SlashedClassName String className) { ClassDescriptor d = DescriptorFactory.createClassDescriptor(className); AnalysisContext.currentXFactory().addReflectiveClasses(d); } }