edu.umd.cs.findbugs
public class BugInstance extends Object implements Comparable<BugInstance>, XMLWriteableWithMessages, Serializable, Cloneable
BugInstance objects are built up by calling a string of add
methods. (These methods all "return this", so they can be chained).
Some of the add methods are specialized to get information automatically from
a BetterVisitor or DismantleBytecode object.
See Also: BugAnnotation
Constructor Summary | |
---|---|
BugInstance(String type, int priority)
Constructor.
| |
BugInstance(Detector detector, String type, int priority)
Create a new BugInstance.
| |
BugInstance(Detector2 detector, String type, int priority)
Create a new BugInstance.
|
Method Summary | |
---|---|
BugInstance | add(BugAnnotation annotation) |
BugInstance | addAnnotations(Collection<? extends BugAnnotation> annotationCollection)
Add a Collection of BugAnnotations.
|
BugInstance | addCalledMethod(DismantleBytecode visitor)
Add a method annotation for the method which has been called
by the method currently being visited by given visitor.
|
BugInstance | addCalledMethod(String className, String methodName, String methodSig, boolean isStatic)
Add a method annotation.
|
BugInstance | addCalledMethod(MethodGen methodGen, InvokeInstruction inv)
Add a method annotation for the method which is called by given
instruction.
|
BugInstance | addClass(String className, String sourceFileName)
Add a class annotation. |
BugInstance | addClass(String className)
Add a class annotation. |
BugInstance | addClass(ClassNode classNode)
Add a class annotation for the classNode.
|
BugInstance | addClass(ClassDescriptor classDescriptor)
Add a class annotation. |
BugInstance | addClass(JavaClass jclass)
Add a class annotation. |
BugInstance | addClass(PreorderVisitor visitor)
Add a class annotation for the class that the visitor is currently visiting.
|
BugInstance | addClassAndMethod(MethodDescriptor methodDescriptor) |
BugInstance | addClassAndMethod(PreorderVisitor visitor)
Add a class annotation and a method annotation for the class and method
which the given visitor is currently visiting.
|
BugInstance | addClassAndMethod(MethodAnnotation methodAnnotation)
Add class and method annotations for given method.
|
BugInstance | addClassAndMethod(MethodGen methodGen, String sourceFile)
Add class and method annotations for given method.
|
BugInstance | addClassAndMethod(JavaClass javaClass, Method method)
Add class and method annotations for given class and method.
|
BugInstance | addField(String className, String fieldName, String fieldSig, boolean isStatic)
Add a field annotation.
|
BugInstance | addField(String className, String fieldName, String fieldSig, int accessFlags)
Add a field annotation.
|
BugInstance | addField(PreorderVisitor visitor) |
BugInstance | addField(FieldAnnotation fieldAnnotation)
Add a field annotation
|
BugInstance | addField(FieldVariable field)
Add a field annotation for a FieldVariable matched in a ByteCodePattern.
|
BugInstance | addField(XField xfield)
Add a field annotation for an XField.
|
BugInstance | addField(FieldDescriptor fieldDescriptor)
Add a field annotation for a FieldDescriptor.
|
BugInstance | addFoundAndExpectedType(String foundType, String expectedType) |
BugInstance | addInt(int value)
Add an integer annotation.
|
BugInstance | addMethod(String className, String methodName, String methodSig, boolean isStatic)
Add a method annotation. |
BugInstance | addMethod(String className, String methodName, String methodSig, int accessFlags)
Add a method annotation. |
BugInstance | addMethod(MethodGen methodGen, String sourceFile)
Add a method annotation. |
BugInstance | addMethod(JavaClass javaClass, Method method)
Add a method annotation. |
BugInstance | addMethod(JavaClassAndMethod classAndMethod)
Add a method annotation. |
BugInstance | addMethod(PreorderVisitor visitor)
Add a method annotation for the method which the given visitor is currently visiting.
|
BugInstance | addMethod(XMethod xmethod)
Add a MethodAnnotation from an XMethod.
|
BugInstance | addMethod(MethodAnnotation methodAnnotation)
Add a method annotation. |
BugInstance | addOptionalAnnotation(BugAnnotation annotation) |
BugInstance | addOptionalField(XField xfield)
Add a field annotation for an XField.
|
BugInstance | addReferencedField(DismantleBytecode visitor)
Add a field annotation for the field which has just been accessed
by the method currently being visited by given visitor.
|
BugInstance | addReferencedField(FieldAnnotation fa)
Add a field annotation for the field referenced by the FieldAnnotation parameter |
BugInstance | addSourceLine(SourceLineAnnotation sourceLine)
Add a source line annotation.
|
BugInstance | addSourceLine(BytecodeScanningDetector visitor, int pc)
Add a source line annotation for instruction whose PC is given
in the method that the given visitor is currently visiting.
|
BugInstance | addSourceLine(ClassContext classContext, PreorderVisitor visitor, int pc)
Add a source line annotation for instruction whose PC is given
in the method that the given visitor is currently visiting.
|
BugInstance | addSourceLine(ClassContext classContext, MethodGen methodGen, String sourceFile, InstructionHandle handle)
Add a source line annotation for the given instruction in the given method.
|
BugInstance | addSourceLine(ClassContext classContext, MethodGen methodGen, String sourceFile, InstructionHandle start, InstructionHandle end)
Add a source line annotation describing a range of instructions.
|
BugInstance | addSourceLine(ClassContext classContext, Method method, Location location)
Add source line annotation for given Location in a method.
|
BugInstance | addSourceLine(ClassContext classContext, Method method, InstructionHandle handle)
Add source line annotation for given Location in a method.
|
BugInstance | addSourceLine(BytecodeScanningDetector visitor)
Add a source line annotation for instruction currently being visited
by given visitor.
|
BugInstance | addSourceLineRange(BytecodeScanningDetector visitor, int startPC, int endPC)
Add a source line annotation describing the
source line numbers for a range of instructions in the method being
visited by the given visitor.
|
BugInstance | addSourceLineRange(ClassContext classContext, PreorderVisitor visitor, int startPC, int endPC)
Add a source line annotation describing the
source line numbers for a range of instructions in the method being
visited by the given visitor.
|
BugInstance | addString(String value)
Add a String annotation.
|
BugInstance | addSuperclass(PreorderVisitor visitor)
Add a class annotation for the superclass of the class the visitor
is currently visiting.
|
BugInstance | addType(String typeDescriptor)
Add a type annotation. |
BugInstance | addTypeOfNamedClass(String typeName) |
BugInstance | addUnknownSourceLine(String className, String sourceFile)
Add a non-specific source line annotation.
|
BugInstance | addVisitedField(PreorderVisitor visitor)
Add a field annotation for the field which is being visited by
given visitor.
|
Iterator<BugAnnotation> | annotationIterator()
Get an Iterator over all bug annotations. |
boolean | annotationTextContainsWord(String word)
Determine whether or not the annotation text contains
the given word.
|
int | compareTo(BugInstance other) |
boolean | deleteProperty(String name)
Delete property with given name.
|
BugInstance | describe(String description)
Add a description to the most recently added bug annotation.
|
String | getAbbrev()
Get the abbreviation of this bug instance's BugPattern.
|
String | getAbridgedMessage() |
String | getCategoryAbbrev() |
long | getFirstVersion() |
String | getInstanceHash() |
String | getInstanceKey() |
int | getInstanceOccurrenceMax() |
int | getInstanceOccurrenceNum() |
long | getLastVersion() |
String | getMessage()
Format a string describing this bug instance.
|
String | getMessageWithoutPrefix()
Format a string describing this bug instance.
|
String | getMessageWithPriorityType()
Format a string describing this bug pattern, with the priority and type at the beginning.
e.g. |
String | getMessageWithPriorityTypeAbbreviation() |
ClassAnnotation | getPrimaryClass()
Get the primary class annotation, which indicates where the bug occurs. |
FieldAnnotation | getPrimaryField()
Get the primary method annotation, which indicates where the bug occurs. |
LocalVariableAnnotation | getPrimaryLocalVariableAnnotation() |
MethodAnnotation | getPrimaryMethod()
Get the primary method annotation, which indicates where the bug occurs. |
SourceLineAnnotation | getPrimarySourceLineAnnotation()
Get the primary source line annotation.
|
int | getPriority()
Get the bug priority. |
String | getPriorityAbbreviation() |
String | getPriorityString() |
String | getPriorityTypeAbbreviation() |
String | getPriorityTypeString()
Get a string describing the bug priority and type.
e.g. |
String | getProperty(String name)
Get value of given property.
|
String | getProperty(String name, String defaultValue)
Get value of given property, returning given default
value if the property has not been set.
|
Set<String> | getTextAnnotationWords()
Get set of words in the text annotation. |
String | getType()
Get the bug type. |
boolean | isExperimental()
Is this bug instance the result of an experimental detector? |
boolean | isInstanceHashConsistent() |
boolean | isIntroducedByChangeOfExistingClass() |
boolean | isRemovedByChangeOfPersistingClass() |
BugProperty | lookupProperty(String name)
Look up a property by name.
|
void | lowerPriority() |
void | lowerPriorityALot() |
BugInstance | lowerPriorityIfDeprecated() |
Iterator<BugProperty> | propertyIterator()
Get an Iterator over the properties defined in this BugInstance.
|
void | raisePriority() |
static void | setAdjustExperimental(boolean adjust) |
void | setAnnotationText(String annotationText)
Set the user annotation text.
|
void | setFirstVersion(long firstVersion) |
void | setInstanceHash(String instanceHash) |
void | setInstanceOccurrenceMax(int instanceOccurrenceMax) |
void | setInstanceOccurrenceNum(int instanceOccurrenceNum) |
void | setIntroducedByChangeOfExistingClass(boolean introducedByChangeOfExistingClass) |
void | setLastVersion(long lastVersion) |
void | setOldInstanceHash(String oldInstanceHash) |
void | setPriority(int p)
Set the bug priority. |
BugInstance | setProperty(String name, String value)
Set value of given property.
|
void | setRemovedByChangeOfPersistingClass(boolean removedByChangeOfPersistingClass) |
void | setUserDesignation(BugDesignation bd) set the user designation object. |
void | writeXML(XMLOutput xmlOutput) |
void | writeXML(XMLOutput xmlOutput, boolean addMessages) |
Parameters: type the bug type priority the bug priority
Parameters: detector the Detector that is reporting the BugInstance type the bug type priority the bug priority
Parameters: detector the Detector2 that is reporting the BugInstance type the bug type priority the bug priority
Parameters: annotationCollection Collection of BugAnnotations
Parameters: visitor the DismantleBytecode object
Returns: this object
Parameters: className name of class containing called method methodName name of called method methodSig signature of called method isStatic true if called method is static, false if not
Returns: this object
Parameters: methodGen the method containing the call inv the InvokeInstruction
Returns: this object
Deprecated: use addClass(String) instead
Add a class annotation. If this is the first class annotation added, it becomes the primary class annotation.Parameters: className the name of the class sourceFileName the source file of the class
Returns: this object
Parameters: className the name of the class
Returns: this object
Parameters: classNode the ASM visitor
Returns: this object
Parameters: classDescriptor the class to add
Returns: this object
Parameters: jclass the JavaClass object for the class
Returns: this object
Parameters: visitor the BetterVisitor
Returns: this object
Parameters: visitor the BetterVisitor
Returns: this object
Parameters: methodAnnotation the method
Returns: this object
Parameters: methodGen the method sourceFile source file the method is defined in
Returns: this object
Parameters: javaClass the class method the method
Returns: this object
Parameters: className name of the class containing the field fieldName the name of the field fieldSig type signature of the field isStatic whether or not the field is static
Returns: this object
Parameters: className name of the class containing the field fieldName the name of the field fieldSig type signature of the field isStatic whether or not the field is static
Returns: this object
Parameters: fieldAnnotation the field annotation
Returns: this object
Parameters: field the FieldVariable
Returns: this object
Parameters: xfield the XField
Returns: this object
Parameters: fieldDescriptor the FieldDescriptor
Returns: this object
Parameters: value the integer value
Returns: this object
Parameters: className name of the class containing the method methodName name of the method methodSig type signature of the method isStatic true if the method is static, false otherwise
Returns: this object
Parameters: className name of the class containing the method methodName name of the method methodSig type signature of the method accessFlags accessFlags for the method
Returns: this object
Parameters: methodGen the MethodGen object for the method sourceFile source file method is defined in
Returns: this object
Parameters: javaClass the class the method is defined in method the method
Returns: this object
Parameters: classAndMethod JavaClassAndMethod identifying the method to add
Returns: this object
Parameters: visitor the BetterVisitor
Returns: this object
Parameters: xmethod the XMethod
Returns: this object
Parameters: methodAnnotation the method annotation
Returns: this object
Parameters: xfield the XField
Returns: this object
Parameters: visitor the DismantleBytecode object
Returns: this object
Parameters: sourceLine the source line annotation
Returns: this object
Parameters: visitor a BytecodeScanningDetector that is currently visiting the method pc bytecode offset of the instruction
Returns: this object
Parameters: classContext the ClassContext visitor a PreorderVisitor that is currently visiting the method pc bytecode offset of the instruction
Returns: this object
Parameters: classContext the ClassContext methodGen the method being visited sourceFile source file the method is defined in handle the InstructionHandle containing the visited instruction
Returns: this object
Parameters: classContext the ClassContext methodGen the method sourceFile source file the method is defined in start the start instruction in the range end the end instruction in the range (inclusive)
Returns: this object
Parameters: classContext the ClassContext method the Method location the Location in the method
Returns: this BugInstance
Parameters: classContext the ClassContext method the Method location the Location in the method
Returns: this BugInstance
Parameters: visitor a BytecodeScanningDetector visitor that is currently visiting the instruction
Returns: this object
Parameters: visitor a BetterVisitor which is visiting the method startPC the bytecode offset of the start instruction in the range endPC the bytecode offset of the end instruction in the range
Returns: this object
Parameters: classContext the ClassContext visitor a BetterVisitor which is visiting the method startPC the bytecode offset of the start instruction in the range endPC the bytecode offset of the end instruction in the range
Returns: this object
Parameters: value the String value
Returns: this object
Parameters: visitor the BetterVisitor
Returns: this object
For information on type descriptors,
see http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#14152
or http://www.murrayc.com/learning/java/java_classfileformat.shtml#TypeDescriptors
Parameters: typeDescriptor a jvm type descriptor, such as "[I"
Returns: this object
Parameters: className the class name sourceFile the source file name
Returns: this object
Parameters: visitor the visitor
Returns: this object
Parameters: word the word
Returns: true if the annotation text contains the word, false otherwise
Parameters: name name of the property to delete
Returns: true if a property with that name was deleted, or false if there is no such property
Parameters: description the description to add
Returns: this object
Returns: Returns the firstVersion.
Returns: Returns the instanceHash.
Returns: Returns the instanceOccurrenceMax.
Returns: Returns the instanceOccurrenceNum.
Returns: Returns the lastVersion.
Returns: the description
Returns: the description
Returns: the source line annotation
Returns: a string describing the bug priority and type
Parameters: name name of the property to get
Returns: the value of the named property, or null if the property has not been set
Parameters: name name of the property to get defaultValue default value to return if propery is not set
Returns: the value of the named property, or the default value if the property has not been set
Returns: Returns the introducedByChangeOfExistingClass.
Returns: Returns the removedByChangeOfPersistingClass.
Parameters: name name of the property to look for
Returns: the BugProperty with the given name, or null if the property has not been set
Returns: Iterator over properties
Parameters: annotationText the user annotation text
Parameters: firstVersion The firstVersion to set.
Parameters: instanceHash The instanceHash to set.
Parameters: instanceOccurrenceMax The instanceOccurrenceMax to set.
Parameters: instanceOccurrenceNum The instanceOccurrenceNum to set.
Parameters: introducedByChangeOfExistingClass The introducedByChangeOfExistingClass to set.
Parameters: lastVersion The lastVersion to set.
Parameters: oldInstanceHash The oldInstanceHash to set.
Parameters: name name of the property to set value the value of the property
Returns: this object, so calls can be chained
Parameters: removedByChangeOfPersistingClass The removedByChangeOfPersistingClass to set.