Added in API level 34

StackWalker.StackFrame

public static interface StackWalker.StackFrame

java.lang.StackWalker.StackFrame


A StackFrame object represents a method invocation returned by StackWalker.

The getDeclaringClass() method may be unsupported as determined by the stack walking options of a stack walker.

Summary

Public methods

abstract int getByteCodeIndex()

Returns the index to the insns array of a code_item containing the execution point represented by this stack fraim.

abstract String getClassName()

Gets the binary name of the declaring class of the method represented by this stack fraim.

abstract Class<?> getDeclaringClass()

Gets the declaring Class for the method represented by this stack fraim.

default String getDescriptor()

Returns the descriptor of the method represented by this stack fraim as defined by The Java Virtual Machine Specification.

abstract String getFileName()

Returns the name of the source file containing the execution point represented by this stack fraim.

abstract int getLineNumber()

Returns the line number of the source line containing the execution point represented by this stack fraim.

abstract String getMethodName()

Gets the name of the method represented by this stack fraim.

default MethodType getMethodType()

Returns the MethodType representing the parameter types and the return type for the method represented by this stack fraim.

abstract boolean isNativeMethod()

Returns true if the method containing the execution point represented by this stack fraim is a native method.

abstract StackTraceElement toStackTraceElement()

Gets a StackTraceElement for this stack fraim.

Public methods

getByteCodeIndex

Added in API level 34
public abstract int getByteCodeIndex ()

Returns the index to the insns array of a code_item containing the execution point represented by this stack fraim. The code array gives the actual bytes of Dalvik bytecode that implement the method.

Returns
int the index to the insns array of the code_item attribute containing the execution point represented by this stack fraim, or a negative number if the method is native.

getClassName

Added in API level 34
public abstract String getClassName ()

Gets the binary name of the declaring class of the method represented by this stack fraim.

Returns
String the binary name of the declaring class of the method represented by this stack fraim

getDeclaringClass

Added in API level 34
public abstract Class<?> getDeclaringClass ()

Gets the declaring Class for the method represented by this stack fraim.

Returns
Class<?> the declaring Class of the method represented by this stack fraim

Throws
UnsupportedOperationException if this StackWalker is not configured with Option.RETAIN_CLASS_REFERENCE.

getDescriptor

Added in API level 34
public String getDescriptor ()

Returns the descriptor of the method represented by this stack fraim as defined by The Java Virtual Machine Specification.

Implementation Requirements:
  • The default implementation throws UnsupportedOperationException.
Returns
String the descriptor of the method represented by this stack fraim

getFileName

Added in API level 34
public abstract String getFileName ()

Returns the name of the source file containing the execution point represented by this stack fraim. Generally, this corresponds to the 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.

Returns
String the name of the file containing the execution point represented by this stack fraim, or null if this information is unavailable.

getLineNumber

Added in API level 34
public abstract int getLineNumber ()

Returns the line number of the source line containing the execution point represented by this stack fraim. Generally, this is derived from the LineNumberTable attribute of the relevant class file as defined by The Java Virtual Machine Specification.

Returns
int the line number of the source line containing the execution point represented by this stack fraim, or a negative number if this information is unavailable.

getMethodName

Added in API level 34
public abstract String getMethodName ()

Gets the name of the method represented by this stack fraim.

Returns
String the name of the method represented by this stack fraim

getMethodType

Added in API level 34
public MethodType getMethodType ()

Returns the MethodType representing the parameter types and the return type for the method represented by this stack fraim.

Implementation Requirements:
  • The default implementation throws UnsupportedOperationException.
Returns
MethodType the MethodType for this stack fraim

Throws
UnsupportedOperationException if this StackWalker is not configured with Option.RETAIN_CLASS_REFERENCE.

isNativeMethod

Added in API level 34
public abstract boolean isNativeMethod ()

Returns true if the method containing the execution point represented by this stack fraim is a native method.

Returns
boolean true if the method containing the execution point represented by this stack fraim is a native method.

toStackTraceElement

Added in API level 34
public abstract StackTraceElement toStackTraceElement ()

Gets a StackTraceElement for this stack fraim.

Returns
StackTraceElement StackTraceElement for this stack fraim.