StackTraceElement.hx 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. package java.lang;
  2. /*
  3. * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  4. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5. *
  6. * This code is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 only, as
  8. * published by the Free Software Foundation. Oracle designates this
  9. * particular file as subject to the "Classpath" exception as provided
  10. * by Oracle in the LICENSE file that accompanied this code.
  11. *
  12. * This code is distributed in the hope that it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  15. * version 2 for more details (a copy is included in the LICENSE file that
  16. * accompanied this code).
  17. *
  18. * You should have received a copy of the GNU General Public License version
  19. * 2 along with this work; if not, write to the Free Software Foundation,
  20. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21. *
  22. * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  23. * or visit www.oracle.com if you need additional information or have any
  24. * questions.
  25. */
  26. /**
  27. * An element in a stack trace, as returned by {@link
  28. * Throwable#getStackTrace()}. Each element represents a single stack frame.
  29. * All stack frames except for the one at the top of the stack represent
  30. * a method invocation. The frame at the top of the stack represents the
  31. * execution point at which the stack trace was generated. Typically,
  32. * this is the point at which the throwable corresponding to the stack trace
  33. * was created.
  34. *
  35. * @since 1.4
  36. * @author Josh Bloch
  37. */
  38. @:require(java4) extern class StackTraceElement implements java.io.Serializable
  39. {
  40. /**
  41. * Creates a stack trace element representing the specified execution
  42. * point.
  43. *
  44. * @param declaringClass the fully qualified name of the class containing
  45. * the execution point represented by the stack trace element
  46. * @param methodName the name of the method containing the execution point
  47. * represented by the stack trace element
  48. * @param fileName the name of the file containing the execution point
  49. * represented by the stack trace element, or {@code null} if
  50. * this information is unavailable
  51. * @param lineNumber the line number of the source line containing the
  52. * execution point represented by this stack trace element, or
  53. * a negative number if this information is unavailable. A value
  54. * of -2 indicates that the method containing the execution point
  55. * is a native method
  56. * @throws NullPointerException if {@code declaringClass} or
  57. * {@code methodName} is null
  58. * @since 1.5
  59. */
  60. @:require(java5) @:overload public function new(declaringClass : String, methodName : String, fileName : String, lineNumber : Int) : Void;
  61. /**
  62. * Returns the name of the source file containing the execution point
  63. * represented by this stack trace element. Generally, this corresponds
  64. * to the {@code SourceFile} attribute of the relevant {@code class}
  65. * file (as per <i>The Java Virtual Machine Specification</i>, Section
  66. * 4.7.7). In some systems, the name may refer to some source code unit
  67. * other than a file, such as an entry in source repository.
  68. *
  69. * @return the name of the file containing the execution point
  70. * represented by this stack trace element, or {@code null} if
  71. * this information is unavailable.
  72. */
  73. @:overload public function getFileName() : String;
  74. /**
  75. * Returns the line number of the source line containing the execution
  76. * point represented by this stack trace element. Generally, this is
  77. * derived from the {@code LineNumberTable} attribute of the relevant
  78. * {@code class} file (as per <i>The Java Virtual Machine
  79. * Specification</i>, Section 4.7.8).
  80. *
  81. * @return the line number of the source line containing the execution
  82. * point represented by this stack trace element, or a negative
  83. * number if this information is unavailable.
  84. */
  85. @:overload public function getLineNumber() : Int;
  86. /**
  87. * Returns the fully qualified name of the class containing the
  88. * execution point represented by this stack trace element.
  89. *
  90. * @return the fully qualified name of the {@code Class} containing
  91. * the execution point represented by this stack trace element.
  92. */
  93. @:overload public function getClassName() : String;
  94. /**
  95. * Returns the name of the method containing the execution point
  96. * represented by this stack trace element. If the execution point is
  97. * contained in an instance or class initializer, this method will return
  98. * the appropriate <i>special method name</i>, {@code <init>} or
  99. * {@code <clinit>}, as per Section 3.9 of <i>The Java Virtual
  100. * Machine Specification</i>.
  101. *
  102. * @return the name of the method containing the execution point
  103. * represented by this stack trace element.
  104. */
  105. @:overload public function getMethodName() : String;
  106. /**
  107. * Returns true if the method containing the execution point
  108. * represented by this stack trace element is a native method.
  109. *
  110. * @return {@code true} if the method containing the execution point
  111. * represented by this stack trace element is a native method.
  112. */
  113. @:overload public function isNativeMethod() : Bool;
  114. /**
  115. * Returns a string representation of this stack trace element. The
  116. * format of this string depends on the implementation, but the following
  117. * examples may be regarded as typical:
  118. * <ul>
  119. * <li>
  120. * {@code "MyClass.mash(MyClass.java:9)"} - Here, {@code "MyClass"}
  121. * is the <i>fully-qualified name</i> of the class containing the
  122. * execution point represented by this stack trace element,
  123. * {@code "mash"} is the name of the method containing the execution
  124. * point, {@code "MyClass.java"} is the source file containing the
  125. * execution point, and {@code "9"} is the line number of the source
  126. * line containing the execution point.
  127. * <li>
  128. * {@code "MyClass.mash(MyClass.java)"} - As above, but the line
  129. * number is unavailable.
  130. * <li>
  131. * {@code "MyClass.mash(Unknown Source)"} - As above, but neither
  132. * the file name nor the line number are available.
  133. * <li>
  134. * {@code "MyClass.mash(Native Method)"} - As above, but neither
  135. * the file name nor the line number are available, and the method
  136. * containing the execution point is known to be a native method.
  137. * </ul>
  138. * @see Throwable#printStackTrace()
  139. */
  140. @:overload public function toString() : String;
  141. /**
  142. * Returns true if the specified object is another
  143. * {@code StackTraceElement} instance representing the same execution
  144. * point as this instance. Two stack trace elements {@code a} and
  145. * {@code b} are equal if and only if:
  146. * <pre>
  147. * equals(a.getFileName(), b.getFileName()) &&
  148. * a.getLineNumber() == b.getLineNumber()) &&
  149. * equals(a.getClassName(), b.getClassName()) &&
  150. * equals(a.getMethodName(), b.getMethodName())
  151. * </pre>
  152. * where {@code equals} has the semantics of {@link
  153. * java.util.Objects#equals(Object, Object) Objects.equals}.
  154. *
  155. * @param obj the object to be compared with this stack trace element.
  156. * @return true if the specified object is another
  157. * {@code StackTraceElement} instance representing the same
  158. * execution point as this instance.
  159. */
  160. @:overload public function equals(obj : Dynamic) : Bool;
  161. /**
  162. * Returns a hash code value for this stack trace element.
  163. */
  164. @:overload public function hashCode() : Int;
  165. }