Module java.base
Package java.lang

Class StackTraceElement

    • 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()
      Returns true if the method name returned by getMethodName() 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 name
        method - The method name
        file - The file name
        line - 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 ClassLoader
        module - The module name
        version - The module version
        cls - The class name
        method - The method name
        file - The file name
        line - 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 class Object
        Parameters:
        obj - the object to compare to
        Returns:
        boolean true if the object is the same as this object false 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.
      • isNativeMethod

        public boolean isNativeMethod()
        Returns true if the method name returned by getMethodName() is implemented as a native method.
        Returns:
        true if the method is a native method
      • toString

        public String toString()
        Returns a string representation of this stack trace element.
        Overrides:
        toString in class Object
        Returns:
        String a printable representation for the receiver.