StackWalkerpublic static interface StackWalker.StackFrame
StackFrame object represents a method invocation returned by StackWalker. Stack walker options configure the stack frame information obtained by a StackWalker. If the stack walker is configured with DROP_METHOD_INFO option, method information such as the method name, the line number, the bytecode index, etc will be dropped. If the stack walker is configured with RETAIN_CLASS_REFERENCE option, the Class object will be retained for access.
| Modifier and Type | Method | Description |
|---|---|---|
int |
getByteCodeIndex() |
Returns the index to the code array of the Code attribute containing the execution point represented by this stack frame. |
String |
getClassName() |
Returns the binary name of the declaring class of the method represented by this stack frame. |
Class |
getDeclaringClass() |
Returns the declaring Class for the method represented by this stack frame. |
default String |
getDescriptor() |
Returns the descriptor of the method represented by this stack frame as defined by The Java Virtual Machine Specification. |
String |
getFileName() |
Returns the name of the source file containing the execution point represented by this stack frame. |
int |
getLineNumber() |
Returns the line number of the source line containing the execution point represented by this stack frame. |
String |
getMethodName() |
Returns the name of the method represented by this stack frame. |
default MethodType |
getMethodType() |
Returns the MethodType representing the parameter types and the return type for the method represented by this stack frame. |
boolean |
isNativeMethod() |
Returns true if the method containing the execution point represented by this stack frame is a native method. |
StackTraceElement |
toStackTraceElement() |
Returns StackTraceElement for this stack frame. |
String getClassName()
String getMethodName()
UnsupportedOperationException - if the StackWalker is configured with DROP_METHOD_INFO optionClass<?> getDeclaringClass()
Class for the method represented by this stack frame.Class for the method represented by this stack frameUnsupportedOperationException - if the StackWalker is configured without RETAIN_CLASS_REFERENCE optiondefault MethodType getMethodType()
MethodType representing the parameter types and the return type for the method represented by this stack frame.UnsupportedOperationException.MethodType of the method represented by this stack frameUnsupportedOperationException - if the StackWalker is configured with DROP_METHOD_INFO option or without RETAIN_CLASS_REFERENCE optiondefault String getDescriptor()
UnsupportedOperationException.UnsupportedOperationException - if the StackWalker is configured with DROP_METHOD_INFO optionint getByteCodeIndex()
Code attribute 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.Code attribute containing the execution point represented by this stack frame, or a negative number if the method is native.UnsupportedOperationException - if the StackWalker is configured with DROP_METHOD_INFO optionCode AttributeString getFileName()
SourceFile attribute of the relevant class file as defined by The 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.null if this information is unavailable.UnsupportedOperationException - if the StackWalker is configured with DROP_METHOD_INFO optionSourceFile Attributeint getLineNumber()
LineNumberTable attribute of the relevant class file as defined by The Java Virtual Machine Specification.UnsupportedOperationException - if the StackWalker is configured with DROP_METHOD_INFO optionLineNumberTable Attributeboolean isNativeMethod()
true if the method containing the execution point represented by this stack frame is a native method.true if the method containing the execution point represented by this stack frame is a native methodUnsupportedOperationException - if the StackWalker is configured with DROP_METHOD_INFO optionStackTraceElement toStackTraceElement()
StackTraceElement for this stack frame.StackTraceElement for this stack frameUnsupportedOperationException - if the StackWalker is configured with DROP_METHOD_INFO option
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/StackWalker.StackFrame.html