- java.lang.Object
-
- java.lang.StackTraceElement
-
- All Implemented Interfaces:
Serializable
public final class StackTraceElement extends Object implements Serializable
StackTraceElement represents a stack frame.- See Also:
Throwable.getStackTrace()
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description StackTraceElement(String cls, String method, String file, int line)
Create a StackTraceElement from the parameters.StackTraceElement(String classLoaderName, String module, String version, String cls, String method, String file, int line)
Create a StackTraceElement from the parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Returns true if the specified object is another StackTraceElement instance representing the same execution point as this instance.String
getClassLoaderName()
Returns the name of the ClassLoader used to load the class for the method in the stack frame.String
getClassName()
Returns the full name (i.e. including package) of the class where this stack trace element is executing.String
getFileName()
If available, returns the name of the file containing the Java code source which was compiled into the class where this stack trace element is executing.int
getLineNumber()
Returns the source file line number for the class where this stack trace element is executing.String
getMethodName()
Returns the name of the method where this stack trace element is executing.String
getModuleName()
Answers the name of the module to which the execution point represented by this stack trace element belongs.String
getModuleVersion()
Answers the version of the module to which the execution point represented by this stack trace element belongs.int
hashCode()
Returns a hash code value for this stack trace element.boolean
isNativeMethod()
Returnstrue
if the method name returned bygetMethodName()
is implemented as a native method.String
toString()
Returns a string representation of this stack trace element.
-
-
-
Constructor Detail
-
StackTraceElement
public StackTraceElement(String cls, String method, String file, int line)
Create a StackTraceElement from the parameters.- Parameters:
cls
- The class namemethod
- The method namefile
- The file nameline
- The line number
-
StackTraceElement
public StackTraceElement(String classLoaderName, String module, String version, String cls, String method, String file, int line)
Create a StackTraceElement from the parameters.- Parameters:
classLoaderName
- The name for the ClassLoadermodule
- The module nameversion
- The module versioncls
- The class namemethod
- The method namefile
- The file nameline
- The line number- Since:
- 9
-
-
Method Detail
-
getClassLoaderName
public String getClassLoaderName()
Returns the name of the ClassLoader used to load the class for the method in the stack frame. See ClassLoader.getName().- Returns:
- name of the Classloader or null
- Since:
- 9
-
equals
public boolean equals(Object obj)
Returns true if the specified object is another StackTraceElement instance representing the same execution point as this instance.- Overrides:
equals
in classObject
- Parameters:
obj
- the object to compare to- Returns:
- boolean
true
if the object is the same as this objectfalse
if it is different from this object. - See Also:
Object.hashCode()
-
getModuleName
public String getModuleName()
Answers the name of the module to which the execution point represented by this stack trace element belongs.- Returns:
- the name of the Module or null if it is not available
-
getModuleVersion
public String getModuleVersion()
Answers the version of the module to which the execution point represented by this stack trace element belongs.- Returns:
- the version of the Module or null if it is not available.
-
getClassName
public String getClassName()
Returns the full name (i.e. including package) of the class where this stack trace element is executing.- Returns:
- the name of the class where this stack trace element is executing.
-
getFileName
public String getFileName()
If available, returns the name of the file containing the Java code source which was compiled into the class where this stack trace element is executing.- Returns:
- the name of the Java code source file which was compiled into the
class where this stack trace element is executing. If not
available, a
null
value is returned.
-
getLineNumber
public int getLineNumber()
Returns the source file line number for the class where this stack trace element is executing.- Returns:
- the line number in the source file corresponding to where this stack trace element is executing.
-
getMethodName
public String getMethodName()
Returns the name of the method where this stack trace element is executing.- Returns:
- the method in which this stack trace element is executing.
Returns <
unknown method
> if the name of the method cannot be determined.
-
hashCode
public int hashCode()
Returns a hash code value for this stack trace element.- Overrides:
hashCode
in classObject
- Returns:
- the receiver's hash.
- See Also:
Object.equals(java.lang.Object)
-
isNativeMethod
public boolean isNativeMethod()
Returnstrue
if the method name returned bygetMethodName()
is implemented as a native method.- Returns:
- true if the method is a native method
-
-