終於知道Java異常棧常常有"....123more"的緣由了

/**this

     * Print our stack trace as a cause for the specified stack trace.ci

     */get

    private void printStackTraceAsCause(PrintStream s,sed

                                        StackTraceElement[] causedTrace)while

    {sse

        // assert Thread.holdsLock(s);co


        // Compute number of frames in common between this and causedvoid

        StackTraceElement[] trace = getOurStackTrace();ab

        int m = trace.length-1, n = causedTrace.length-1;

        while (m >= 0 && n >=0 && trace[m].equals(causedTrace[n])) {

            m--; n--;

        }

        int framesInCommon = trace.length - 1 - m;


        s.println("Caused by: " + this);

        for (int i=0; i <= m; i++)

            s.println("\tat " + trace[i]);

        if (framesInCommon != 0)

            s.println("\t... " + framesInCommon + " more");


        // Recurse if we have a cause

        Throwable ourCause = getCause();

        if (ourCause != null)

            ourCause.printStackTraceAsCause(s, trace);

    }

相關文章
相關標籤/搜索