/** * Add a field annotation. * * @param className * name of the class containing the field * @param fieldName * the name of the field * @param fieldSig * type signature of the field * @param accessFlags * access flags for the field * @return this object */ @Nonnull public BugInstance addField(String className, String fieldName, String fieldSig, int accessFlags) { addField(new FieldAnnotation(className, fieldName, fieldSig, accessFlags)); return this; }
/** * Add a field annotation. * * @param className * name of the class containing the field * @param fieldName * the name of the field * @param fieldSig * type signature of the field * @param isStatic * whether or not the field is static * @return this object */ @Nonnull public BugInstance addField(String className, String fieldName, String fieldSig, boolean isStatic) { addField(new FieldAnnotation(className, fieldName, fieldSig, isStatic)); return this; }
/** * Is the given instruction a read of a field? * * @param ins * the Instruction to check * @param cpg * ConstantPoolGen of the method containing the instruction * @return the Field if the instruction is a read of a field, null otherwise */ public static FieldAnnotation isRead(Instruction ins, ConstantPoolGen cpg) { if (ins instanceof GETFIELD || ins instanceof GETSTATIC) { FieldInstruction fins = (FieldInstruction) ins; String className = fins.getClassName(cpg); return new FieldAnnotation(className, fins.getName(cpg), fins.getSignature(cpg), fins instanceof GETSTATIC); } else { return null; } }
/** * Is the instruction a write of a field? * * @param ins * the Instruction to check * @param cpg * ConstantPoolGen of the method containing the instruction * @return the Field if instruction is a write of a field, null otherwise */ public static FieldAnnotation isWrite(Instruction ins, ConstantPoolGen cpg) { if (ins instanceof PUTFIELD || ins instanceof PUTSTATIC) { FieldInstruction fins = (FieldInstruction) ins; String className = fins.getClassName(cpg); return new FieldAnnotation(className, fins.getName(cpg), fins.getSignature(cpg), fins instanceof PUTSTATIC); } else { return null; } }
/** * Factory method. Class name, field name, and field signatures are taken * from the given visitor, which is visiting the field. * * @param visitor * the visitor which is visiting the field * @return the FieldAnnotation object */ public static FieldAnnotation fromVisitedField(PreorderVisitor visitor) { return new FieldAnnotation(visitor.getDottedClassName(), visitor.getFieldName(), visitor.getFieldSig(), visitor.getFieldIsStatic()); }
/** * Factory method. Construct from class name and BCEL Field object. * * @param className * the name of the class which defines the field * @param field * the BCEL Field object * @return the FieldAnnotation */ public static FieldAnnotation fromBCELField(@DottedClassName String className, Field field) { return new FieldAnnotation(className, field.getName(), field.getSignature(), field.isStatic()); }
/** * Factory method. Construct from class name and BCEL Field object. * * @param jClass * the class which defines the field * @param field * the BCEL Field object * @return the FieldAnnotation */ public static FieldAnnotation fromBCELField(JavaClass jClass, Field field) { return new FieldAnnotation(jClass.getClassName(), field.getName(), field.getSignature(), field.isStatic()); }
/** * Factory method. Class name, field name, and field signatures are taken * from the given visitor, which is visiting a reference to the field (i.e., * a getfield or getstatic instruction). * * @param visitor * the visitor which is visiting the field reference * @return the FieldAnnotation object */ public static FieldAnnotation fromReferencedField(DismantleBytecode visitor) { String className = visitor.getDottedClassConstantOperand(); return new FieldAnnotation(className, visitor.getNameConstantOperand(), visitor.getSigConstantOperand(), visitor.getRefFieldIsStatic()); }
/** * Factory method. Construct from a FieldDescriptor. * * @param fieldDescriptor * the FieldDescriptor * @return the FieldAnnotation */ public static FieldAnnotation fromFieldDescriptor(FieldDescriptor fieldDescriptor) { return new FieldAnnotation(fieldDescriptor.getClassDescriptor().getDottedClassName(), fieldDescriptor.getName(), fieldDescriptor.getSignature(), fieldDescriptor.isStatic()); }
public static FieldAnnotation fromXField(XField fieldDescriptor) { return new FieldAnnotation(fieldDescriptor.getClassName(), fieldDescriptor.getName(), fieldDescriptor.getSignature(), fieldDescriptor.getSourceSignature(), fieldDescriptor.isStatic()); }
String isStatic = getRequiredAttribute(attributes, "isStatic", qName); String sourceSignature = getOptionalAttribute(attributes, "sourceSignature"); bugAnnotation = bugAnnotationWithSourceLines = new FieldAnnotation(classname, fieldOrMethodName, signature, sourceSignature, Boolean.valueOf(isStatic));
static FieldAnnotation obfuscate(FieldAnnotation m) { FieldAnnotation result = new FieldAnnotation(hashClass(m.getClassName()), hashData(m.getFieldName()), hashSignature(m.getFieldSignature()), m.isStatic()); result.setDescription(m.getDescription()); return result; }
/** * Rewrite a FieldAnnotation to update the class name and field signature, * if needed. * * @param classNameRewriter * a ClassNameRewriter * @param annotation * a FieldAnnotation * @return the possibly-rewritten FieldAnnotation */ public static FieldAnnotation convertFieldAnnotation(ClassNameRewriter classNameRewriter, FieldAnnotation annotation) { if (classNameRewriter != IdentityClassNameRewriter.instance()) { annotation = new FieldAnnotation(classNameRewriter.rewriteClassName(annotation.getClassName()), annotation.getFieldName(), rewriteSignature(classNameRewriter, annotation.getFieldSignature()), annotation.isStatic()); } return annotation; }
@Override public void visitField(Field obj) { if (obj.isProtected()) { bugReporter.reportBug(new BugInstance(this, "CI_CONFUSED_INHERITANCE", LOW_PRIORITY).addClass(cls).addField( new FieldAnnotation(cls.getClassName(), obj.getName(), obj.getSignature(), obj.isStatic()))); } }
Field maskingField = classFields.get(fieldName); String mClassName = getDottedClassName(); FieldAnnotation fa = new FieldAnnotation(mClassName, maskingField.getName(), maskingField.getSignature(), maskingField.isStatic()); int priority = NORMAL_PRIORITY;
: "MTIA_SUSPECT_SERVLET_INSTANCE_FIELD", LOW_PRIORITY) .addField( new FieldAnnotation(getDottedClassName(), nameCons.getBytes(), typeCons.getBytes(), false)).addClass(this).addSourceLine(this));
/** * Factory method. Class name, field name, and field signatures are taken * from the given visitor, which is visiting the field. * * @param visitor * the visitor which is visiting the field * @return the FieldAnnotation object */ public static FieldAnnotation fromVisitedField(PreorderVisitor visitor) { return new FieldAnnotation(visitor.getDottedClassName(), visitor.getFieldName(), visitor.getFieldSig(), visitor.getFieldIsStatic()); }
/** * Factory method. Construct from class name and BCEL Field object. * * @param className * the name of the class which defines the field * @param field * the BCEL Field object * @return the FieldAnnotation */ public static FieldAnnotation fromBCELField(@DottedClassName String className, Field field) { return new FieldAnnotation(className, field.getName(), field.getSignature(), field.isStatic()); }
/** * Factory method. Construct from class name and BCEL Field object. * * @param jClass * the class which defines the field * @param field * the BCEL Field object * @return the FieldAnnotation */ public static FieldAnnotation fromBCELField(JavaClass jClass, Field field) { return new FieldAnnotation(jClass.getClassName(), field.getName(), field.getSignature(), field.isStatic()); }
static FieldAnnotation obfuscate(FieldAnnotation m) { FieldAnnotation result = new FieldAnnotation(hashClass(m.getClassName()), hashData(m.getFieldName()), hashSignature(m.getFieldSignature()), m.isStatic()); result.setDescription(m.getDescription()); return result; }