Package edu.umd.cs.findbugs
Class FieldAnnotation
java.lang.Object
edu.umd.cs.findbugs.BugAnnotationWithSourceLines
edu.umd.cs.findbugs.PackageMemberAnnotation
edu.umd.cs.findbugs.FieldAnnotation
- All Implemented Interfaces:
BugAnnotation
,XMLWriteable
,XMLWriteableWithMessages
,Serializable
,Cloneable
,Comparable<BugAnnotation>
A BugAnnotation specifying a particular field in particular class.
- Author:
- David Hovemeyer
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class edu.umd.cs.findbugs.PackageMemberAnnotation
className, description
Fields inherited from class edu.umd.cs.findbugs.BugAnnotationWithSourceLines
sourceFileName, sourceLines
Fields inherited from interface edu.umd.cs.findbugs.BugAnnotation
MESSAGE_TAG
-
Constructor Summary
ConstructorsConstructorDescriptionFieldAnnotation
(String className, String fieldName, String fieldSig, boolean isStatic) Constructor.FieldAnnotation
(String className, String fieldName, String fieldSig, int accessFlags) Constructor.FieldAnnotation
(String className, String fieldName, String fieldSig, String fieldSourceSig, boolean isStatic) -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(BugAnnotationVisitor visitor) Accept a BugAnnotationVisitor.int
boolean
protected String
formatPackageMember
(String key, ClassAnnotation primaryClass) Do default and subclass-specific formatting.static FieldAnnotation
fromBCELField
(String className, org.apache.bcel.classfile.Field field) Factory method.static FieldAnnotation
fromBCELField
(org.apache.bcel.classfile.JavaClass jClass, org.apache.bcel.classfile.Field field) Factory method.static FieldAnnotation
fromFieldDescriptor
(FieldDescriptor fieldDescriptor) Factory method.static FieldAnnotation
fromReferencedField
(DismantleBytecode visitor) Factory method.static FieldAnnotation
fromVisitedField
(PreorderVisitor visitor) Factory method.static FieldAnnotation
fromXField
(XField fieldDescriptor) Get the field name.Get the type signature of the field.Get the SourceLineAnnotation describing the source lines where the method is defined.int
hashCode()
static FieldAnnotation
isRead
(org.apache.bcel.generic.Instruction ins, org.apache.bcel.generic.ConstantPoolGen cpg) Is the given instruction a read of a field?boolean
isStatic()
Return whether or not the field is static.static FieldAnnotation
isWrite
(org.apache.bcel.generic.Instruction ins, org.apache.bcel.generic.ConstantPoolGen cpg) Is the instruction a write of a field?toXField()
void
Write this object to given XMLOutput.void
Methods inherited from class edu.umd.cs.findbugs.PackageMemberAnnotation
format, getClassDescriptor, getClassName, getDescription, getPackageName, getSimpleClassName, getSlashedClassName, isSignificant, removePackage, removePackageName, setDescription, shorten, toString, toString
Methods inherited from class edu.umd.cs.findbugs.BugAnnotationWithSourceLines
clone, getSourceFileName, setSourceLines
-
Field Details
-
DEFAULT_ROLE
- See Also:
-
DID_YOU_MEAN_ROLE
- See Also:
-
VALUE_OF_ROLE
- See Also:
-
LOADED_FROM_ROLE
- See Also:
-
STORED_ROLE
- See Also:
-
INVOKED_ON_ROLE
- See Also:
-
ARGUMENT_ROLE
- See Also:
-
-
Constructor Details
-
FieldAnnotation
public FieldAnnotation(@DottedClassName String className, String fieldName, String fieldSig, boolean isStatic) Constructor.- Parameters:
className
- the name of the class containing the fieldfieldName
- the name of the fieldfieldSig
- the type signature of the field
-
FieldAnnotation
public FieldAnnotation(@DottedClassName String className, String fieldName, String fieldSig, String fieldSourceSig, boolean isStatic) -
FieldAnnotation
public FieldAnnotation(@DottedClassName String className, String fieldName, String fieldSig, int accessFlags) Constructor.- Parameters:
className
- the name of the class containing the fieldfieldName
- the name of the fieldfieldSig
- the type signature of the fieldaccessFlags
- accessFlags for the field
-
-
Method Details
-
fromVisitedField
Factory method. Class name, field name, and field signatures are taken from the given visitor, which is visiting the field.- Parameters:
visitor
- the visitor which is visiting the field- Returns:
- the FieldAnnotation object
-
fromReferencedField
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).- Parameters:
visitor
- the visitor which is visiting the field reference- Returns:
- the FieldAnnotation object
-
fromBCELField
public static FieldAnnotation fromBCELField(@DottedClassName String className, org.apache.bcel.classfile.Field field) Factory method. Construct from class name and BCEL Field object.- Parameters:
className
- the name of the class which defines the fieldfield
- the BCEL Field object- Returns:
- the FieldAnnotation
-
fromBCELField
public static FieldAnnotation fromBCELField(org.apache.bcel.classfile.JavaClass jClass, org.apache.bcel.classfile.Field field) Factory method. Construct from class name and BCEL Field object.- Parameters:
jClass
- the class which defines the fieldfield
- the BCEL Field object- Returns:
- the FieldAnnotation
-
fromFieldDescriptor
Factory method. Construct from a FieldDescriptor.- Parameters:
fieldDescriptor
- the FieldDescriptor- Returns:
- the FieldAnnotation
-
fromXField
-
toXField
-
toFieldDescriptor
-
getFieldName
Get the field name. -
getFieldSignature
Get the type signature of the field. -
isStatic
public boolean isStatic()Return whether or not the field is static. -
isRead
public static FieldAnnotation isRead(org.apache.bcel.generic.Instruction ins, org.apache.bcel.generic.ConstantPoolGen cpg) Is the given instruction a read of a field?- Parameters:
ins
- the Instruction to checkcpg
- ConstantPoolGen of the method containing the instruction- Returns:
- the Field if the instruction is a read of a field, null otherwise
-
isWrite
public static FieldAnnotation isWrite(org.apache.bcel.generic.Instruction ins, org.apache.bcel.generic.ConstantPoolGen cpg) Is the instruction a write of a field?- Parameters:
ins
- the Instruction to checkcpg
- ConstantPoolGen of the method containing the instruction- Returns:
- the Field if instruction is a write of a field, null otherwise
-
accept
Description copied from interface:BugAnnotation
Accept a BugAnnotationVisitor.- Parameters:
visitor
- the visitor to accept
-
formatPackageMember
Description copied from class:PackageMemberAnnotation
Do default and subclass-specific formatting.- Specified by:
formatPackageMember
in classPackageMemberAnnotation
- Parameters:
key
- the key specifying how to do the formattingprimaryClass
- TODO
-
hashCode
public int hashCode() -
equals
-
compareTo
-
getSourceLines
Description copied from class:BugAnnotationWithSourceLines
Get the SourceLineAnnotation describing the source lines where the method is defined.- Overrides:
getSourceLines
in classBugAnnotationWithSourceLines
- Returns:
- the SourceLineAnnotation, or null if there is no source information for this package element
-
writeXML
Description copied from interface:XMLWriteable
Write this object to given XMLOutput.- Parameters:
xmlOutput
- the XMLOutput for the document- Throws:
IOException
-
writeXML
public void writeXML(XMLOutput xmlOutput, boolean addMessages, boolean isPrimary) throws IOException - Throws:
IOException
-