public class SourceLineAnnotation extends Object implements BugAnnotation
BugAnnotation
,
Serialized FormModifier and Type | Field and Description |
---|---|
static char |
CANONICAL_PACKAGE_SEPARATOR |
static String |
DEFAULT_ROLE |
static String |
DEFAULT_ROLE_UNKNOWN_LINE |
static String |
DESCRIPTION_LAST_CHANGE |
static String |
DESCRIPTION_LOOP_BOTTOM |
static String |
ROLE_ANOTHER_INSTANCE |
static String |
ROLE_CALLED_FROM_SUPERCLASS_AT |
static String |
ROLE_FIELD_SET_TOO_LATE_AT |
static String |
ROLE_GENERATED_AT |
static String |
ROLE_LOCK_OBTAINED_AT |
static String |
ROLE_OBLIGATION_CREATED |
static String |
ROLE_OBLIGATION_CREATED_BY_WILLCLOSE_PARAMETER |
static String |
ROLE_PATH_CONTINUES |
static String |
ROLE_UNREACHABLE_CODE |
static String |
UNKNOWN_SOURCE_FILE
String returned if the source file is unknown.
|
MESSAGE_TAG
Constructor and Description |
---|
SourceLineAnnotation(String className,
String sourceFile,
int startLine,
int endLine,
int startBytecode,
int endBytecode)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(BugAnnotationVisitor visitor)
Accept a BugAnnotationVisitor.
|
static void |
clearGenerateRelativeSource() |
Object |
clone() |
int |
compareTo(BugAnnotation o) |
static SourceLineAnnotation |
createReallyUnknown(String className)
Factory method to create an unknown source line annotation.
|
static SourceLineAnnotation |
createUnknown(String className)
Factory method to create an unknown source line annotation.
|
static SourceLineAnnotation |
createUnknown(String className,
String sourceFile)
Factory method to create an unknown source line annotation.
|
static SourceLineAnnotation |
createUnknown(String className,
String sourceFile,
int startBytecode,
int endBytecode)
Factory method to create an unknown source line annotation.
|
boolean |
equals(Object o) |
static SourceLineAnnotation |
forEntireMethod(org.apache.bcel.classfile.JavaClass javaClass,
org.apache.bcel.classfile.Method method)
Create a SourceLineAnnotation covering an entire method.
|
static SourceLineAnnotation |
forEntireMethod(org.apache.bcel.classfile.JavaClass javaClass,
XMethod xmethod)
Create a SourceLineAnnotation covering an entire method.
|
static SourceLineAnnotation |
forEntireMethod(String className,
String sourceFile,
org.apache.bcel.classfile.LineNumberTable lineNumberTable,
int codeSize)
Create a SourceLineAnnotation covering an entire method.
|
static SourceLineAnnotation |
forFirstLineOfMethod(MethodDescriptor methodDescriptor)
Make a best-effort attempt to create a SourceLineAnnotation for the first
line of a method.
|
String |
format(String key,
ClassAnnotation primaryClass)
Format the annotation as a String.
|
static SourceLineAnnotation |
fromRawData(String className,
String sourceFile,
int startLine,
int endLine,
int startPC,
int endPC) |
static SourceLineAnnotation |
fromVisitedInstruction(BytecodeScanningDetector visitor)
Factory method for creating a source line annotation describing the
source line number for the instruction being visited by given visitor.
|
static SourceLineAnnotation |
fromVisitedInstruction(BytecodeScanningDetector visitor,
int pc)
Factory method for creating a source line annotation describing the
source line number for the instruction being visited by given visitor.
|
static SourceLineAnnotation |
fromVisitedInstruction(ClassContext classContext,
org.apache.bcel.generic.MethodGen methodGen,
String sourceFile,
org.apache.bcel.generic.InstructionHandle handle)
Factory method for creating a source line annotation describing the
source line number for a visited instruction.
|
static SourceLineAnnotation |
fromVisitedInstruction(ClassContext classContext,
org.apache.bcel.classfile.Method method,
org.apache.bcel.generic.InstructionHandle handle)
Create from Method and InstructionHandle in a visited class.
|
static SourceLineAnnotation |
fromVisitedInstruction(ClassContext classContext,
org.apache.bcel.classfile.Method method,
int pc)
Create from Method and bytecode offset in a visited class.
|
static SourceLineAnnotation |
fromVisitedInstruction(ClassContext classContext,
org.apache.bcel.classfile.Method method,
Location loc)
Create from Method and Location in a visited class.
|
static SourceLineAnnotation |
fromVisitedInstruction(ClassContext classContext,
PreorderVisitor visitor,
int pc)
Factory method for creating a source line annotation describing the
source line number for the instruction being visited by given visitor.
|
static SourceLineAnnotation |
fromVisitedInstruction(org.apache.bcel.classfile.JavaClass jclass,
org.apache.bcel.classfile.Method method,
int pc)
Create from Method and bytecode offset in a visited class.
|
static SourceLineAnnotation |
fromVisitedInstruction(MethodDescriptor methodDescriptor,
int position) |
static SourceLineAnnotation |
fromVisitedInstruction(MethodDescriptor methodDescriptor,
Location location)
Create from MethodDescriptor and Location of visited instruction.
|
static SourceLineAnnotation |
fromVisitedInstructionRange(BytecodeScanningDetector visitor,
int startPC,
int endPC)
Factory method for creating a source line annotation describing the
source line numbers for a range of instructions in the method being
visited by the given visitor.
|
static SourceLineAnnotation |
fromVisitedInstructionRange(ClassContext classContext,
org.apache.bcel.generic.MethodGen methodGen,
String sourceFile,
org.apache.bcel.generic.InstructionHandle start,
org.apache.bcel.generic.InstructionHandle end)
Factory method for creating a source line annotation describing the
source line numbers for a range of instruction in a method.
|
static SourceLineAnnotation |
fromVisitedInstructionRange(ClassContext classContext,
PreorderVisitor visitor,
int startPC,
int endPC)
Factory method for creating a source line annotation describing the
source line numbers for a range of instructions in the method being
visited by the given visitor.
|
static SourceLineAnnotation |
fromVisitedMethod(org.apache.bcel.generic.MethodGen methodGen,
String sourceFile)
Factory method for creating a source line annotation describing an entire
method.
|
static SourceLineAnnotation |
fromVisitedMethod(PreorderVisitor visitor)
Factory method for creating a source line annotation describing an entire
method.
|
static void |
generateRelativeSource(File relativeSourceBase,
Project project) |
String |
getClassName() |
String |
getDescription()
Get a description of this bug annotation.
|
int |
getEndBytecode()
Get end bytecode (inclusive).
|
int |
getEndLine()
Get the ending line (inclusive).
|
String |
getPackageName() |
String |
getSimpleClassName()
Get the simple class name (the part of the name after the dot)
|
String |
getSourceFile()
Get the source file name.
|
String |
getSourcePath() |
int |
getStartBytecode()
Get start bytecode (inclusive).
|
int |
getStartLine()
Get the start line (inclusive).
|
int |
hashCode() |
boolean |
isSignificant()
Is this annotation used to compute instance hashes or match bug instances
across versions
|
boolean |
isSourceFileKnown()
Is the source file known?
|
boolean |
isSynthetic() |
boolean |
isUnknown()
Is this an unknown source line annotation?
|
void |
setDescription(String description)
Set a description of this bug annotation.
|
void |
setSourceFile(String sourceFile)
Set the source file name.
|
void |
setSynthetic(boolean synthetic) |
String |
toString() |
String |
toString(ClassAnnotation primaryClass) |
void |
writeXML(XMLOutput xmlOutput)
Write this object to given XMLOutput.
|
void |
writeXML(XMLOutput xmlOutput,
boolean addMessages,
boolean isPrimary) |
public static final String DEFAULT_ROLE
public static final String DEFAULT_ROLE_UNKNOWN_LINE
public static final String ROLE_ANOTHER_INSTANCE
public static final String ROLE_CALLED_FROM_SUPERCLASS_AT
public static final String ROLE_FIELD_SET_TOO_LATE_AT
public static final String ROLE_GENERATED_AT
public static final String ROLE_OBLIGATION_CREATED
public static final String ROLE_OBLIGATION_CREATED_BY_WILLCLOSE_PARAMETER
public static final String ROLE_PATH_CONTINUES
public static final String ROLE_LOCK_OBTAINED_AT
public static final String ROLE_UNREACHABLE_CODE
public static final String UNKNOWN_SOURCE_FILE
public static final char CANONICAL_PACKAGE_SEPARATOR
public static final String DESCRIPTION_LAST_CHANGE
public static final String DESCRIPTION_LOOP_BOTTOM
public SourceLineAnnotation(@Nonnull@DottedClassName String className, @Nonnull String sourceFile, int startLine, int endLine, int startBytecode, int endBytecode)
className
- the class to which the line number(s) refersourceFile
- the name of the source filestartLine
- the first line (inclusive)endLine
- the ending line (inclusive)startBytecode
- the first bytecode offset (inclusive)endBytecode
- the end bytecode offset (inclusive)public Object clone()
clone
in interface BugAnnotation
clone
in class Object
public static SourceLineAnnotation createUnknown(@DottedClassName String className, String sourceFile)
className
- the class namesourceFile
- the source file namepublic static SourceLineAnnotation createUnknown(@DottedClassName String className)
className
- the class namepublic static SourceLineAnnotation createReallyUnknown(@DottedClassName String className)
className
- the class name@Nonnull public static SourceLineAnnotation createUnknown(@DottedClassName String className, String sourceFile, int startBytecode, int endBytecode)
className
- the class namesourceFile
- the source file namepublic static SourceLineAnnotation fromVisitedMethod(PreorderVisitor visitor)
visitor
- a BetterVisitor which is visiting the methodpublic static SourceLineAnnotation fromVisitedMethod(org.apache.bcel.generic.MethodGen methodGen, String sourceFile)
methodGen
- the method being visitedpublic static SourceLineAnnotation forEntireMethod(@DottedClassName String className, String sourceFile, org.apache.bcel.classfile.LineNumberTable lineNumberTable, int codeSize)
className
- name of the class the method is insourceFile
- source file containing the methodlineNumberTable
- the method's LineNumberTablecodeSize
- size in bytes of the method's codepublic static SourceLineAnnotation forEntireMethod(org.apache.bcel.classfile.JavaClass javaClass, @CheckForNull org.apache.bcel.classfile.Method method)
javaClass
- JavaClass containing the methodmethod
- the methodpublic static SourceLineAnnotation forEntireMethod(org.apache.bcel.classfile.JavaClass javaClass, XMethod xmethod)
javaClass
- JavaClass containing the methodxmethod
- the methodpublic static SourceLineAnnotation forFirstLineOfMethod(MethodDescriptor methodDescriptor)
methodDescriptor
- a methodpublic static SourceLineAnnotation fromVisitedInstruction(BytecodeScanningDetector visitor, int pc)
visitor
- a BetterVisitor which is visiting the methodpc
- the bytecode offset of the instruction in the methodpublic static SourceLineAnnotation fromVisitedInstruction(ClassContext classContext, PreorderVisitor visitor, int pc)
classContext
- the ClassContextvisitor
- a BetterVisitor which is visiting the methodpc
- the bytecode offset of the instruction in the methodpublic static SourceLineAnnotation fromVisitedInstruction(ClassContext classContext, org.apache.bcel.classfile.Method method, Location loc)
classContext
- ClassContext of visited classmethod
- Method in visited classloc
- Location in visited classpublic static SourceLineAnnotation fromVisitedInstruction(ClassContext classContext, org.apache.bcel.classfile.Method method, org.apache.bcel.generic.InstructionHandle handle)
classContext
- ClassContext of visited classmethod
- Method in visited classhandle
- InstructionHandle in visited classpublic static SourceLineAnnotation fromVisitedInstruction(MethodDescriptor methodDescriptor, Location location)
methodDescriptor
- MethodDescriptor identifying analyzed methodlocation
- Location of instruction within analyed methodpublic static SourceLineAnnotation fromVisitedInstruction(MethodDescriptor methodDescriptor, int position)
public static SourceLineAnnotation fromVisitedInstruction(ClassContext classContext, org.apache.bcel.classfile.Method method, int pc)
classContext
- ClassContext of visited classmethod
- Method in visited classpc
- bytecode offset in visited methodpublic static SourceLineAnnotation fromVisitedInstruction(org.apache.bcel.classfile.JavaClass jclass, org.apache.bcel.classfile.Method method, int pc)
jclass
- JavaClass of visited classmethod
- Method in visited classpc
- bytecode offset in visited methodpublic static SourceLineAnnotation fromVisitedInstructionRange(BytecodeScanningDetector visitor, int startPC, int endPC)
visitor
- a BetterVisitor which is visiting the methodstartPC
- the bytecode offset of the start instruction in the rangeendPC
- the bytecode offset of the end instruction in the range@Nonnull public static SourceLineAnnotation fromVisitedInstructionRange(ClassContext classContext, PreorderVisitor visitor, int startPC, int endPC)
classContext
- the ClassContextvisitor
- a BetterVisitor which is visiting the methodstartPC
- the bytecode offset of the start instruction in the rangeendPC
- the bytecode offset of the end instruction in the rangepublic static SourceLineAnnotation fromRawData(String className, String sourceFile, int startLine, int endLine, int startPC, int endPC)
public static SourceLineAnnotation fromVisitedInstruction(BytecodeScanningDetector visitor)
visitor
- a DismantleBytecode visitor which is visiting the method@Nonnull public static SourceLineAnnotation fromVisitedInstruction(ClassContext classContext, org.apache.bcel.generic.MethodGen methodGen, String sourceFile, @Nonnull org.apache.bcel.generic.InstructionHandle handle)
classContext
- the ClassContextmethodGen
- the MethodGen object representing the methodhandle
- the InstructionHandle containing the visited instructionpublic static SourceLineAnnotation fromVisitedInstructionRange(ClassContext classContext, org.apache.bcel.generic.MethodGen methodGen, String sourceFile, org.apache.bcel.generic.InstructionHandle start, org.apache.bcel.generic.InstructionHandle end)
classContext
- theClassContextmethodGen
- the methodstart
- the start instructionend
- the end instruction (inclusive)@Nonnull @DottedClassName public String getClassName()
public boolean isSourceFileKnown()
public void setSourceFile(String sourceFile)
sourceFile
- the source file namepublic String getSimpleClassName()
public String getPackageName()
public int getStartLine()
public int getEndLine()
public int getStartBytecode()
public int getEndBytecode()
public boolean isUnknown()
public void accept(BugAnnotationVisitor visitor)
BugAnnotation
accept
in interface BugAnnotation
visitor
- the visitor to acceptpublic String format(String key, ClassAnnotation primaryClass)
BugAnnotation
format
in interface BugAnnotation
key
- how the annotation should be formattedprimaryClass
- The primary class for the bug; some bug annotation format msgs
are simplified in relation to that class.public String getDescription()
BugAnnotation
getDescription
in interface BugAnnotation
public void setDescription(String description)
BugAnnotation
setDescription
in interface BugAnnotation
public int compareTo(BugAnnotation o)
compareTo
in interface Comparable<BugAnnotation>
public void writeXML(XMLOutput xmlOutput) throws IOException
XMLWriteable
writeXML
in interface XMLWriteable
xmlOutput
- the XMLOutput for the documentIOException
public static void generateRelativeSource(File relativeSourceBase, Project project)
public static void clearGenerateRelativeSource()
public void writeXML(XMLOutput xmlOutput, boolean addMessages, boolean isPrimary) throws IOException
writeXML
in interface XMLWriteableWithMessages
IOException
public String getSourcePath()
public void setSynthetic(boolean synthetic)
public boolean isSynthetic()
public boolean isSignificant()
BugAnnotation
isSignificant
in interface BugAnnotation
public String toString(ClassAnnotation primaryClass)
toString
in interface BugAnnotation
Copyright © 2003–2015. All rights reserved.