< prev index next >

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

Print this page

        

@@ -22,11 +22,10 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
 package java.lang;
-import jdk.internal.misc.VM;
 
 import  java.io.*;
 import  java.util.*;
 
 /**

@@ -824,15 +823,11 @@
     private synchronized StackTraceElement[] getOurStackTrace() {
         // Initialize stack trace field with information from
         // backtrace if this is the first call to this method
         if (stackTrace == UNASSIGNED_STACK ||
             (stackTrace == null && backtrace != null) /* Out of protocol state */) {
-            stackTrace = new StackTraceElement[depth];
-            for (int i = 0; i < depth; i++) {
-                stackTrace[i] = new StackTraceElement();
-            }
-            getStackTraceElements(stackTrace);
+            stackTrace = StackTraceElement.of(this, depth);
         } else if (stackTrace == null) {
             return UNASSIGNED_STACK;
         }
         return stackTrace;
     }

@@ -880,17 +875,10 @@
             this.stackTrace = defensiveCopy;
         }
     }
 
     /**
-     * Gets the stack trace elements.
-     * @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
      * suppressedExceptions}.  Null entries are not allowed for stack
      * trace elements.  A null stack trace in the serial form results
< prev index next >