< prev index next >

src/java.base/share/classes/java/lang/Throwable.java

Print this page

        

*** 209,218 **** --- 209,223 ---- * @serial * @since 1.4 */ private StackTraceElement[] stackTrace = UNASSIGNED_STACK; + /** + * Native code sets the depth of the backtrace for later retrieval + */ + private transient int depth; + // Setting this static field introduces an acceptable // initialization dependency on a few java.util classes. private static final List<Throwable> SUPPRESSED_SENTINEL = Collections.emptyList(); /**
*** 826,839 **** if (stackTrace == UNASSIGNED_STACK || (stackTrace == null && backtrace != null) /* Out of protocol state */) { if (backtrace instanceof StackStreamFactory.StackTrace) { stackTrace = ((StackStreamFactory.StackTrace)backtrace).getStackTraceElements(); } else { - int depth = getStackTraceDepth(); stackTrace = new StackTraceElement[depth]; ! for (int i = 0; i < depth; i++) ! stackTrace[i] = getStackTraceElement(i); } } else if (stackTrace == null) { return UNASSIGNED_STACK; } return stackTrace; --- 831,845 ---- if (stackTrace == UNASSIGNED_STACK || (stackTrace == null && backtrace != null) /* Out of protocol state */) { if (backtrace instanceof StackStreamFactory.StackTrace) { stackTrace = ((StackStreamFactory.StackTrace)backtrace).getStackTraceElements(); } else { stackTrace = new StackTraceElement[depth]; ! for (int i = 0; i < depth; i++) { ! stackTrace[i] = new StackTraceElement(); ! } ! getStackTraceElements(stackTrace); } } else if (stackTrace == null) { return UNASSIGNED_STACK; } return stackTrace;
*** 882,908 **** this.stackTrace = defensiveCopy; } } /** ! * Returns the number of elements in the stack trace (or 0 if the stack ! * trace is unavailable). ! * ! * package-protection for use by SharedSecrets. ! */ ! native int getStackTraceDepth(); ! ! /** ! * Returns the specified element of the stack trace. ! * ! * package-protection for use by SharedSecrets. ! * ! * @param index index of the element to return. ! * @throws IndexOutOfBoundsException if {@code index < 0 || ! * index >= getStackTraceDepth() } */ ! native StackTraceElement getStackTraceElement(int index); /** * Reads a {@code Throwable} from a stream, enforcing * well-formedness constraints on fields. Null entries and * self-pointers are not allowed in the list of {@code --- 888,901 ---- this.stackTrace = defensiveCopy; } } /** ! * @param elements ! * @throws IndexOutOfBoundsException if {@code elements.length != depth } */ ! private native void getStackTraceElements(StackTraceElement[] elements); /** * Reads a {@code Throwable} from a stream, enforcing * well-formedness constraints on fields. Null entries and * self-pointers are not allowed in the list of {@code
< prev index next >