public final class StackTraceElement extends Object implements Serializable
StackTraceElement
are stored in Throwable objects to represent the whole state of the
call stack at the time a Throwable gets thrown.Throwable.getStackTrace(),
Serialized Form| Constructor and Description |
|---|
StackTraceElement(String cls,
String method,
String file,
int line)
Constructs a new
StackTraceElement for a specified execution
point. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj)
Compares this instance with the specified object and indicates if they
are equal.
|
String |
getClassName()
Returns the fully qualified name of the class belonging to this
StackTraceElement. |
String |
getFileName()
Returns the name of the Java source file containing class belonging to
this
StackTraceElement. |
int |
getLineNumber()
Returns the line number in the source for the class belonging to this
StackTraceElement. |
String |
getMethodName()
Returns the name of the method belonging to this
StackTraceElement. |
int |
hashCode()
Returns an integer hash code for this object.
|
boolean |
isNativeMethod()
Indicates if the method name returned by
getMethodName() is
implemented as a native method. |
String |
toString()
Returns a string containing a concise, human-readable description of this
object.
|
public StackTraceElement(String cls, String method, String file, int line)
StackTraceElement for a specified execution
point.cls - the fully qualified name of the class where execution is at.method - the name of the method where execution is at.file - The name of the file where execution is at or null.line - the line of the file where execution is at, a negative number
if unknown or -2 if the execution is in a native
method.NullPointerException - if cls or method is null.public boolean equals(Object obj)
obj must be a stack trace element,obj must
not be null,obj must be equal.equals in class Objectobj - the object to compare this instance with.true if the specified object is equal to this
StackTraceElement; false otherwise.hashCode()public String getClassName()
StackTraceElement.public String getFileName()
StackTraceElement.null if this information is not
available.public int getLineNumber()
StackTraceElement.public String getMethodName()
StackTraceElement.public int hashCode()
ObjectObject.equals(java.lang.Object) returns true must return
the same hash code value. This means that subclasses of Object
usually override both methods or neither method.
Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCode method
if you intend implementing your own hashCode method.
hashCode in class ObjectObject.equals(java.lang.Object)public boolean isNativeMethod()
getMethodName() is
implemented as a native method.true if the method in which this stack trace element is
executing is a native method; false otherwise.public String toString()
ObjectgetClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toString method
if you intend implementing your own toString method.