1 *java.lang.StackTraceElement* *StackTraceElement* An element in a stack trace, a
3 public final class StackTraceElement
4 extends |java.lang.Object|
5 implements |java.io.Serializable|
7 |java.lang.StackTraceElement_Description|
8 |java.lang.StackTraceElement_Fields|
9 |java.lang.StackTraceElement_Constructors|
10 |java.lang.StackTraceElement_Methods|
12 ================================================================================
14 *java.lang.StackTraceElement_Constructors*
15 |java.lang.StackTraceElement(String,String,String,int)|Creates a stack trace el
17 *java.lang.StackTraceElement_Methods*
18 |java.lang.StackTraceElement.equals(Object)|Returns true if the specified objec
19 |java.lang.StackTraceElement.getClassName()|Returns the fully qualified name of
20 |java.lang.StackTraceElement.getFileName()|Returns the name of the source file
21 |java.lang.StackTraceElement.getLineNumber()|Returns the line number of the sou
22 |java.lang.StackTraceElement.getMethodName()|Returns the name of the method con
23 |java.lang.StackTraceElement.hashCode()|Returns a hash code value for this stac
24 |java.lang.StackTraceElement.isNativeMethod()|Returns true if the method contai
25 |java.lang.StackTraceElement.toString()|Returns a string representation of this
27 *java.lang.StackTraceElement_Description*
29 An element in a stack trace, as returned by (|java.lang.Throwable|) . Each
30 element represents a single stack frame. All stack frames except for the one at
31 the top of the stack represent a method invocation. The frame at the top of the
32 stack represents the execution point at which the stack trace was generated.
33 Typically, this is the point at which the throwable corresponding to the stack
38 *java.lang.StackTraceElement(String,String,String,int)*
40 public StackTraceElement(
41 java.lang.String declaringClass,
42 java.lang.String methodName,
43 java.lang.String fileName,
46 Creates a stack trace element representing the specified execution point.
48 declaringClass - the fully qualified name of the class containing the execution point
49 represented by the stack trace element
50 methodName - the name of the method containing the execution point represented by the stack
52 fileName - the name of the file containing the execution point represented by the stack
53 trace element, or null if this information is unavailable
54 lineNumber - the line number of the source line containing the execution point represented
55 by this stack trace element, or a negative number if this information is
56 unavailable. A value of -2 indicates that the method containing the
57 execution point is a native method
59 *java.lang.StackTraceElement.equals(Object)*
61 public boolean equals(java.lang.Object obj)
63 Returns true if the specified object is another StackTraceElement instance
64 representing the same execution point as this instance. Two stack trace
65 elements a and b are equal if and only if:
67 equals(a.getFileName(), b.getFileName()) a.getLineNumber() ==
68 b.getLineNumber()) equals(a.getClassName(), b.getClassName())
69 equals(a.getMethodName(), b.getMethodName())
71 where equals is defined as:
73 static boolean equals(Object a, Object b) { return a==b || (a != null
77 obj - the object to be compared with this stack trace element.
79 Returns: true if the specified object is another StackTraceElement instance representing
80 the same execution point as this instance.
82 *java.lang.StackTraceElement.getClassName()*
84 public |java.lang.String| getClassName()
86 Returns the fully qualified name of the class containing the execution point
87 represented by this stack trace element.
91 Returns: the fully qualified name of the Class containing the execution point
92 represented by this stack trace element.
94 *java.lang.StackTraceElement.getFileName()*
96 public |java.lang.String| getFileName()
98 Returns the name of the source file containing the execution point represented
99 by this stack trace element. Generally, this corresponds to the SourceFile
100 attribute of the relevant class file (as per The Java Virtual Machine
101 Specification, Section 4.7.7). In some systems, the name may refer to some
102 source code unit other than a file, such as an entry in source repository.
106 Returns: the name of the file containing the execution point represented by this stack
107 trace element, or null if this information is unavailable.
109 *java.lang.StackTraceElement.getLineNumber()*
111 public int getLineNumber()
113 Returns the line number of the source line containing the execution point
114 represented by this stack trace element. Generally, this is derived from the
115 LineNumberTable attribute of the relevant class file (as per The Java Virtual
116 Machine Specification, Section 4.7.8).
120 Returns: the line number of the source line containing the execution point represented
121 by this stack trace element, or a negative number if this
122 information is unavailable.
124 *java.lang.StackTraceElement.getMethodName()*
126 public |java.lang.String| getMethodName()
128 Returns the name of the method containing the execution point represented by
129 this stack trace element. If the execution point is contained in an instance or
130 class initializer, this method will return the appropriate special method name,
131 <init> or <clinit>, as per Section 3.9 of The Java Virtual Machine
136 Returns: the name of the method containing the execution point represented by this stack
139 *java.lang.StackTraceElement.hashCode()*
141 public int hashCode()
143 Returns a hash code value for this stack trace element.
147 *java.lang.StackTraceElement.isNativeMethod()*
149 public boolean isNativeMethod()
151 Returns true if the method containing the execution point represented by this
152 stack trace element is a native method.
156 Returns: true if the method containing the execution point represented by this stack
157 trace element is a native method.
159 *java.lang.StackTraceElement.toString()*
161 public |java.lang.String| toString()
163 Returns a string representation of this stack trace element. The format of this
164 string depends on the implementation, but the following examples may be
167 "MyClass.mash(MyClass.java:9)" - Here, "MyClass" is the fully-qualified name of
168 the class containing the execution point represented by this stack trace
169 element, "mash" is the name of the method containing the execution point,
170 "MyClass.java" is the source file containing the execution point, and "9" is
171 the line number of the source line containing the execution point.
173 "MyClass.mash(MyClass.java)" - As above, but the line number is unavailable.
175 "MyClass.mash(Unknown Source)" - As above, but neither the file name nor the
176 line number are available.
178 "MyClass.mash(Native Method)" - As above, but neither the file name nor the
179 line number are available, and the method containing the execution point is
180 known to be a native method.