Map.Entry<XField, OpcodeStack.Item> entry = i.next(); XField f = entry.getKey(); if ( AnalysisContext.currentXFactory().isReflectiveClass(f.getClassDescriptor())) { i.remove(); removed++;
@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)); } } }
public static boolean isServletField(XField field) { ClassDescriptor classDescriptor = field.getClassDescriptor(); try { Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2(); if (subtypes2.isSubtype(classDescriptor, servlet) && !subtypes2.isSubtype(classDescriptor, singleThreadedServlet)) { return true; } } catch (ClassNotFoundException e) { assert true; } if (classDescriptor.getClassName().endsWith("Servlet")) { return true; } return false; }
XClass xClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, f.getClassDescriptor()); movedOutofInterface = couldBePackage && xClass.isInterface(); } catch (CheckedAnalysisException e) {
if (seen == Const.PUTFIELD) { XField xField = getXFieldOperand(); if (xField != null && xField.getClassDescriptor().equals(getClassDescriptor())) { Item first = stack.getStackItem(0);
XFactory xFactory = AnalysisContext.currentXFactory(); for (XField f : AnalysisContext.currentXFactory().allFields()) { ClassDescriptor classDescriptor = f.getClassDescriptor(); if (currentAnalysisContext.isApplicationClass(classDescriptor) && !currentAnalysisContext.isTooBig(classDescriptor) && !xFactory.isReflectiveClass(classDescriptor)) { classContainingNullOnlyFields.add(f.getClassDescriptor()); int increment = 3; Collection<ProgramPoint> assumedNonNullAt = data.assumedNonNull.get(f); } else if (nullOnlyFieldNames.getCount(f.getName()) > 8) { assumeReflective.add(f); } else if (classContainingNullOnlyFields.getCount(f.getClassDescriptor()) > 4) { assumeReflective.add(f); } else if (classContainingNullOnlyFields.getCount(f.getClassDescriptor()) > 2 && f.getName().length() == 1) { assumeReflective.add(f); XClass thisClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, f.getClassDescriptor()); if (r instanceof ObjectType) { ClassDescriptor c = DescriptorFactory.getClassDescriptor((ObjectType) r); if (subtypes2.isSubtype(f.getClassDescriptor(), c)) { ProgramPoint p = data.threadLocalAssignedInConstructor.get(of); int priority = p == null ? NORMAL_PRIORITY : HIGH_PRIORITY; if (isAnonymousInnerClass) { bugInstance = new BugInstance(this, "SIC_INNER_SHOULD_BE_STATIC_ANON", priority); List<BugAnnotation> annotations = anonymousClassAnnotation.remove(f.getClassDescriptor().getDottedClassName()); if(annotations != null) {
@Override public void sawOpcode(int seen) { if(skip) { return; } if(isBranch(seen) || seen == Const.ATHROW || isReturn(seen)) { skip = true; } if(seen == Const.PUTFIELD) { XField xField = getXFieldOperand(); if(xField != null && xField.getClassDescriptor().getClassName().equals(getClassName())) { Item val = getStack().getStackItem(0); if(val.isInitialParameter()) { reporter.reportBug(new BugInstance("ME_ENUM_FIELD_SETTER", NORMAL_PRIORITY).addClassAndMethod(this).addField(xField) .addSourceLine(this)); } } } } }
private MethodCall getMethodCall(MethodDescriptor methodDescriptorOperand) { Item objItem = getStack().getStackItem(getNumberArguments(methodDescriptorOperand.getSignature())); if (isNew(objItem)) { return new MethodCall(methodDescriptorOperand, TARGET_NEW); } if (objItem.getRegisterNumber() == 0 && !getMethod().isStatic()) { return new MethodCall(methodDescriptorOperand, constructor ? TARGET_NEW : TARGET_THIS); } XField xField = objItem.getXField(); if (xField != null) { if (classInit && xField.isStatic() && xField.getClassDescriptor().getClassName().equals(getClassName())) { return new MethodCall(methodDescriptorOperand, TARGET_NEW); } if (!getMethodDescriptor().isStatic() && objItem.getFieldLoadedFromRegister() == 0 && allowedFields.contains(xField.getFieldDescriptor())) { fieldsModifyingMethods.add(getMethodDescriptor()); return new MethodCall(methodDescriptorOperand, xField.getFieldDescriptor()); } } return new MethodCall(methodDescriptorOperand, TARGET_OTHER); }
if (f == null || !f.getClassDescriptor().equals(getClassDescriptor())) { return;
if (!fieldOperand.getClassDescriptor().getClassName().equals(getClassName())) { fieldSummary.addWrittenOutsideOfConstructor(fieldOperand); } else if (seen == Const.PUTFIELD) {
XField xField = (XField)field; if((xField.isPublic() || xField.isProtected())) { XClass xClass = AnalysisContext.currentXFactory().getXClass(xField.getClassDescriptor()); if(xClass != null && xClass.isPublic()) { priority = NORMAL_PRIORITY;
Map.Entry<XField, OpcodeStack.Item> entry = i.next(); XField f = entry.getKey(); if ( AnalysisContext.currentXFactory().isReflectiveClass(f.getClassDescriptor())) { i.remove(); removed++;
@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)); } } }
public static boolean isServletField(XField field) { ClassDescriptor classDescriptor = field.getClassDescriptor(); try { Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2(); if (subtypes2.isSubtype(classDescriptor, servlet) && !subtypes2.isSubtype(classDescriptor, singleThreadedServlet)) { return true; } } catch (ClassNotFoundException e) { assert true; } if (classDescriptor.getClassName().endsWith("Servlet")) { return true; } return false; }
XClass xClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, f.getClassDescriptor()); movedOutofInterface = couldBePackage && xClass.isInterface(); } catch (CheckedAnalysisException e) {
if (seen == PUTFIELD) { XField xField = getXFieldOperand(); if (xField != null && xField.getClassDescriptor().equals(getClassDescriptor())) { Item first = stack.getStackItem(0);
@Override public void sawOpcode(int seen) { if(skip) { return; } if(isBranch(seen) || seen == ATHROW || isReturn(seen)) { skip = true; } if(seen == PUTFIELD) { XField xField = getXFieldOperand(); if(xField != null && xField.getClassDescriptor().getClassName().equals(getClassName())) { Item val = getStack().getStackItem(0); if(val.isInitialParameter()) { reporter.reportBug(new BugInstance("ME_ENUM_FIELD_SETTER", NORMAL_PRIORITY).addClassAndMethod(this).addField(xField) .addSourceLine(this)); } } } } }
private MethodCall getMethodCall(MethodDescriptor methodDescriptorOperand) { Item objItem = getStack().getStackItem(getNumberArguments(methodDescriptorOperand.getSignature())); if (isNew(objItem)) { return new MethodCall(methodDescriptorOperand, TARGET_NEW); } if (objItem.getRegisterNumber() == 0 && !getMethod().isStatic()) { return new MethodCall(methodDescriptorOperand, constructor ? TARGET_NEW : TARGET_THIS); } XField xField = objItem.getXField(); if (xField != null) { if (classInit && xField.isStatic() && xField.getClassDescriptor().getClassName().equals(getClassName())) { return new MethodCall(methodDescriptorOperand, TARGET_NEW); } if (!getMethodDescriptor().isStatic() && objItem.getFieldLoadedFromRegister() == 0 && allowedFields.contains(xField.getFieldDescriptor())) { fieldsModifyingMethods.add(getMethodDescriptor()); return new MethodCall(methodDescriptorOperand, xField.getFieldDescriptor()); } } return new MethodCall(methodDescriptorOperand, TARGET_OTHER); }
if (!fieldOperand.getClassDescriptor().getClassName().equals(getClassName())) { fieldSummary.addWrittenOutsideOfConstructor(fieldOperand); } else if (seen == PUTFIELD) {
if (f == null || !f.getClassDescriptor().equals(getClassDescriptor())) { return;