Module java.base
Package java.lang

Interface StackWalker.StackFrame

Enclosing class:
StackWalker

public static interfaceStackWalker.StackFrame
AStackFrame object represents a method invocation returned byStackWalker.

ThegetDeclaringClass() method may be unsupported as determined by thestack walking options of astack walker.

SeeJava Virtual Machine Specification:
2.6
Since:
9
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the index to the code array of theCode attribute containing the execution point represented by this stack frame.
    Gets thebinary name of the declaring class of the method represented by this stack frame.
    Gets the declaringClass for the method represented by this stack frame.
    defaultString
    Returns 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.
    int
    Returns the line number of the source line containing the execution point represented by this stack frame.
    Gets the name of the method represented by this stack frame.
    defaultMethodType
    Returns theMethodType representing the parameter types and the return type for the method represented by this stack frame.
    boolean
    Returnstrue if the method containing the execution point represented by this stack frame is a native method.
    Gets aStackTraceElement for this stack frame.
  • Method Details

    • getClassName

      String getClassName()
      Gets thebinary name of the declaring class of the method represented by this stack frame.
      Returns:
      the binary 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()
      Gets the name of the method represented by this stack frame.
      Returns:
      the name of the method represented by this stack frame
    • getDeclaringClass

      Class<?> getDeclaringClass()
      Gets the declaringClass for the method represented by this stack frame.
      Returns:
      the declaringClass of the method represented by this stack frame
      Throws:
      UnsupportedOperationException - if thisStackWalker is not configured withOption.RETAIN_CLASS_REFERENCE.
    • getMethodType

      default MethodType getMethodType()
      Returns theMethodType representing the parameter types and the return type for the method represented by this stack frame.
      Implementation Requirements:
      The default implementation throwsUnsupportedOperationException.
      Returns:
      theMethodType for this stack frame
      Throws:
      UnsupportedOperationException - if thisStackWalker is not configured withOption.RETAIN_CLASS_REFERENCE.
      Since:
      10
    • getDescriptor

      default String getDescriptor()
      Returns thedescriptor of the method represented by this stack frame as defined byThe Java Virtual Machine Specification.
      Implementation Requirements:
      The default implementation throwsUnsupportedOperationException.
      Returns:
      the descriptor of the method represented by this stack frame
      SeeJava Virtual Machine Specification:
      4.3.3 Method Descriptor
      Since:
      10
      See Also:
    • getByteCodeIndex

      int getByteCodeIndex()
      Returns the index to the code array of theCode 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.
      Returns:
      the index to the code array of theCode attribute containing the execution point represented by this stack frame, or a negative number if the method is native.
      SeeJava Virtual Machine Specification:
      4.7.3 TheCode Attribute
    • getFileName

      String getFileName()
      Returns the name of the source file containing the execution point represented by this stack frame. Generally, this corresponds to theSourceFile attribute of the relevantclass file 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, ornull if this information is unavailable.
      SeeJava Virtual Machine Specification:
      4.7.10 TheSourceFile Attribute
    • 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 theLineNumberTable attribute of the relevantclass file 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.
      SeeJava Virtual Machine Specification:
      4.7.12 TheLineNumberTable Attribute
    • isNativeMethod

      boolean isNativeMethod()
      Returnstrue if the method containing the execution point represented by this stack frame is a native method.
      Returns:
      true if the method containing the execution point represented by this stack frame is a native method.
    • toStackTraceElement

      StackTraceElement toStackTraceElement()
      Gets aStackTraceElement for this stack frame.
      Returns:
      StackTraceElement for this stack frame.