Package com.tonic.analysis.verifier
Class VerificationError
- java.lang.Object
-
- com.tonic.analysis.verifier.VerificationError
-
public final class VerificationError extends Object
One immutable verification finding: a typed error or warning with an optional bytecode offset and location.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classVerificationError.SeveritySeverity of a finding: ERROR fails verification, WARNING does not.
-
Constructor Summary
Constructors Constructor Description VerificationError(VerificationErrorType type, int bytecodeOffset, String message)Creates an ERROR-severity finding with no location.VerificationError(VerificationErrorType type, int bytecodeOffset, String message, VerificationError.Severity severity)Creates a finding with an explicit severity and no location.VerificationError(VerificationErrorType type, int bytecodeOffset, String message, VerificationError.Severity severity, String className, String methodName)Creates a finding with an explicit severity and location; null message and severity fall back to the type's description and ERROR.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)Stringformat()Formats this finding as one line with severity, type, location, offset, and message.intgetBytecodeOffset()StringgetClassName()StringgetMessage()StringgetMethodName()VerificationError.SeveritygetSeverity()VerificationErrorTypegetType()inthashCode()booleanisError()booleanisWarning()StringtoString()VerificationErrorwithLocation(String className, String methodName)Copies this error with a class and method location attached.
-
-
-
Constructor Detail
-
VerificationError
public VerificationError(VerificationErrorType type, int bytecodeOffset, String message)
Creates an ERROR-severity finding with no location.- Parameters:
type- the error categorybytecodeOffset- the offending bytecode offset, or -1 if not tied to an offsetmessage- the detail message, or null for the type's description
-
VerificationError
public VerificationError(VerificationErrorType type, int bytecodeOffset, String message, VerificationError.Severity severity)
Creates a finding with an explicit severity and no location.- Parameters:
type- the error categorybytecodeOffset- the offending bytecode offset, or -1 if not tied to an offsetmessage- the detail message, or null for the type's descriptionseverity- the severity, or null for ERROR
-
VerificationError
public VerificationError(VerificationErrorType type, int bytecodeOffset, String message, VerificationError.Severity severity, String className, String methodName)
Creates a finding with an explicit severity and location; null message and severity fall back to the type's description and ERROR.- Parameters:
type- the error categorybytecodeOffset- the offending bytecode offset, or -1 if not tied to an offsetmessage- the detail message, or null for the type's descriptionseverity- the severity, or null for ERRORclassName- the enclosing class name, or nullmethodName- the enclosing method name, or null
-
-
Method Detail
-
withLocation
public VerificationError withLocation(String className, String methodName)
Copies this error with a class and method location attached.- Parameters:
className- the enclosing class namemethodName- the enclosing method name- Returns:
- a new error with the location set
-
getType
public VerificationErrorType getType()
- Returns:
- the type
-
getBytecodeOffset
public int getBytecodeOffset()
- Returns:
- the bytecode offset
-
getMessage
public String getMessage()
- Returns:
- the message
-
getSeverity
public VerificationError.Severity getSeverity()
- Returns:
- the severity
-
getMethodName
public String getMethodName()
- Returns:
- the method name
-
getClassName
public String getClassName()
- Returns:
- the class name
-
isError
public boolean isError()
- Returns:
- true if severity is ERROR
-
isWarning
public boolean isWarning()
- Returns:
- true if severity is WARNING
-
format
public String format()
Formats this finding as one line with severity, type, location, offset, and message.- Returns:
- the formatted line
-
-