Interface StackWalker.StackFrame
- Enclosing class:
StackWalker
public static interfaceStackWalker.StackFrame
A
StackFrame object represents a method invocation returned byStackWalker.Stack walker options configure the stack frame information obtained by aStackWalker. If the stack walker is configured withDROP_METHOD_INFO option, method information such as themethod name, theline number, thebytecode index, etc will be dropped. If the stack walker is configured withRETAIN_CLASS_REFERENCE option, theClass object will be retained for access.
- SeeJava Virtual Machine Specification:
- 2.6 Frames
- Since:
- 9
Method Summary
Modifier and TypeMethodDescriptionintReturns the index to the code array of theCodeattribute containing the execution point represented by this stack frame.Returns thebinary name of the declaring class of the method represented by this stack frame.Class<?> Returns the declaringClassfor the method represented by this stack frame.defaultStringReturns thedescriptor of the method represented by this stack frame as defined byThe Java Virtual Machine Specification.Returns the name of the source file containing the execution point represented by this stack frame.intReturns the line number of the source line containing the execution point represented by this stack frame.Returns the name of the method represented by this stack frame.defaultMethodTypeReturns theMethodTyperepresenting the parameter types and the return type for the method represented by this stack frame.booleanReturnstrueif the method containing the execution point represented by this stack frame is a native method.ReturnsStackTraceElementfor this stack frame.
Method Details
getClassName
String getClassName()Returns thebinary name of the declaring class of the method represented by this stack frame.- Returns:
- thebinary name of the declaring class of the method represented by this stack frame
- SeeJava Language Specification:
- 13.1 The Form of a Binary
getMethodName
String getMethodName()Returns the name of the method represented by this stack frame.- Returns:
- the name of the method represented by this stack frame
- Throws:
UnsupportedOperationException- if theStackWalkeris configured withDROP_METHOD_INFOoption
getDeclaringClass
Class<?> getDeclaringClass()Returns the declaringClassfor the method represented by this stack frame.- Returns:
- the declaring
Classfor the method represented by this stack frame - Throws:
UnsupportedOperationException- if theStackWalkeris configured withoutRETAIN_CLASS_REFERENCEoption
getMethodType
Returns theMethodTyperepresenting the parameter types and the return type for the method represented by this stack frame.- Implementation Requirements:
- The default implementation throws
UnsupportedOperationException. - Returns:
- the
MethodTypeof the method represented by this stack frame - Throws:
UnsupportedOperationException- if theStackWalkeris configured withDROP_METHOD_INFOoption or withoutRETAIN_CLASS_REFERENCEoption- Since:
- 10
getDescriptor
Returns thedescriptor of the method represented by this stack frame as defined byThe Java Virtual Machine Specification.- Implementation Requirements:
- The default implementation throws
UnsupportedOperationException. - Returns:
- the descriptor of the method represented by this stack frame
- Throws:
UnsupportedOperationException- if theStackWalkeris configured withDROP_METHOD_INFOoption- SeeJava Virtual Machine Specification:
- 4.3.3 Method Descriptors
- Since:
- 10
- See Also:
getByteCodeIndex
int getByteCodeIndex()Returns the index to the code array of theCodeattribute containing the execution point represented by this stack frame. The code array gives the actual bytes of Java Virtual Machine code that implement the method.- Returns:
- the index to the code array of the
Codeattribute containing the execution point represented by this stack frame, or a negative number if the method is native. - Throws:
UnsupportedOperationException- if theStackWalkeris configured withDROP_METHOD_INFOoption- SeeJava Virtual Machine Specification:
- 4.7.3 The
CodeAttribute
getFileName
String getFileName()Returns the name of the source file containing the execution point represented by this stack frame. Generally, this corresponds to theSourceFileattribute of the relevantclassfile as defined byThe Java Virtual Machine Specification. In some systems, the name may refer to some source code unit other than a file, such as an entry in a source repository.- Returns:
- the name of the file containing the execution point represented by this stack frame, or
nullif this information is unavailable. - Throws:
UnsupportedOperationException- if theStackWalkeris configured withDROP_METHOD_INFOoption- SeeJava Virtual Machine Specification:
- 4.7.10 The
SourceFileAttribute
getLineNumber
int getLineNumber()Returns the line number of the source line containing the execution point represented by this stack frame. Generally, this is derived from theLineNumberTableattribute of the relevantclassfile as defined byThe Java Virtual Machine Specification.- Returns:
- the line number of the source line containing the execution point represented by this stack frame, or a negative number if this information is unavailable.
- Throws:
UnsupportedOperationException- if theStackWalkeris configured withDROP_METHOD_INFOoption- SeeJava Virtual Machine Specification:
- 4.7.12 The
LineNumberTableAttribute
isNativeMethod
boolean isNativeMethod()Returnstrueif the method containing the execution point represented by this stack frame is a native method.- Returns:
trueif the method containing the execution point represented by this stack frame is a native method- Throws:
UnsupportedOperationException- if theStackWalkeris configured withDROP_METHOD_INFOoption
toStackTraceElement
StackTraceElement toStackTraceElement()ReturnsStackTraceElementfor this stack frame.- Returns:
StackTraceElementfor this stack frame- Throws:
UnsupportedOperationException- if theStackWalkeris configured withDROP_METHOD_INFOoption