rt/emul/mini/src/main/java/java/lang/Throwable.java
branchjavac
changeset 1313 f08854c7f8b1
parent 1255 3d8730a21c74
child 1426 d5d280615f60
     1.1 --- a/rt/emul/mini/src/main/java/java/lang/Throwable.java	Thu Aug 29 16:49:00 2013 +0000
     1.2 +++ b/rt/emul/mini/src/main/java/java/lang/Throwable.java	Sat Sep 28 02:03:14 2013 +0200
     1.3 @@ -641,90 +641,28 @@
     1.4      @JavaScriptBody(args = {  }, body = "console.warn(this.toString());")
     1.5      public native void printStackTrace();
     1.6  
     1.7 -//    /**
     1.8 -//     * Prints this throwable and its backtrace to the specified print stream.
     1.9 -//     *
    1.10 -//     * @param s {@code PrintStream} to use for output
    1.11 -//     */
    1.12 -//    public void printStackTrace(PrintStream s) {
    1.13 -//        printStackTrace(new WrappedPrintStream(s));
    1.14 -//    }
    1.15 -//
    1.16 -//    private void printStackTrace(PrintStreamOrWriter s) {
    1.17 -//        // Guard against malicious overrides of Throwable.equals by
    1.18 -//        // using a Set with identity equality semantics.
    1.19 -////        Set<Throwable> dejaVu =
    1.20 -////            Collections.newSetFromMap(new IdentityHashMap<Throwable, Boolean>());
    1.21 -////        dejaVu.add(this);
    1.22 -//
    1.23 -//        synchronized (s.lock()) {
    1.24 -//            // Print our stack trace
    1.25 -//            s.println(this);
    1.26 -//            StackTraceElement[] trace = getOurStackTrace();
    1.27 -//            for (StackTraceElement traceElement : trace)
    1.28 -//                s.println("\tat " + traceElement);
    1.29 -//
    1.30 -//            // Print suppressed exceptions, if any
    1.31 -////            for (Throwable se : getSuppressed())
    1.32 -////                se.printEnclosedStackTrace(s, trace, SUPPRESSED_CAPTION, "\t", dejaVu);
    1.33 -//
    1.34 -//            // Print cause, if any
    1.35 -//            Throwable ourCause = getCause();
    1.36 -////            if (ourCause != null)
    1.37 -////                ourCause.printEnclosedStackTrace(s, trace, CAUSE_CAPTION, "", dejaVu);
    1.38 -//        }
    1.39 -//    }
    1.40 -//
    1.41 -//    /**
    1.42 -//     * Print our stack trace as an enclosed exception for the specified
    1.43 -//     * stack trace.
    1.44 -//     */
    1.45 -//    private void printEnclosedStackTrace(PrintStreamOrWriter s,
    1.46 -//                                         StackTraceElement[] enclosingTrace,
    1.47 -//                                         String caption,
    1.48 -//                                         String prefix,
    1.49 -//                                         Object dejaVu) {
    1.50 -//        assert Thread.holdsLock(s.lock());
    1.51 -//        {
    1.52 -//            // Compute number of frames in common between this and enclosing trace
    1.53 -//            StackTraceElement[] trace = getOurStackTrace();
    1.54 -//            int m = trace.length - 1;
    1.55 -//            int n = enclosingTrace.length - 1;
    1.56 -//            while (m >= 0 && n >=0 && trace[m].equals(enclosingTrace[n])) {
    1.57 -//                m--; n--;
    1.58 -//            }
    1.59 -//            int framesInCommon = trace.length - 1 - m;
    1.60 -//
    1.61 -//            // Print our stack trace
    1.62 -//            s.println(prefix + caption + this);
    1.63 -//            for (int i = 0; i <= m; i++)
    1.64 -//                s.println(prefix + "\tat " + trace[i]);
    1.65 -//            if (framesInCommon != 0)
    1.66 -//                s.println(prefix + "\t... " + framesInCommon + " more");
    1.67 -//
    1.68 -//            // Print suppressed exceptions, if any
    1.69 -//            for (Throwable se : getSuppressed())
    1.70 -//                se.printEnclosedStackTrace(s, trace, SUPPRESSED_CAPTION,
    1.71 -//                                           prefix +"\t", dejaVu);
    1.72 -//
    1.73 -//            // Print cause, if any
    1.74 -//            Throwable ourCause = getCause();
    1.75 -//            if (ourCause != null)
    1.76 -//                ourCause.printEnclosedStackTrace(s, trace, CAUSE_CAPTION, prefix, dejaVu);
    1.77 -//        }
    1.78 -//    }
    1.79 -//
    1.80 -//    /**
    1.81 -//     * Prints this throwable and its backtrace to the specified
    1.82 -//     * print writer.
    1.83 -//     *
    1.84 -//     * @param s {@code PrintWriter} to use for output
    1.85 -//     * @since   JDK1.1
    1.86 -//     */
    1.87 -//    public void printStackTrace(PrintWriter s) {
    1.88 -//        printStackTrace(new WrappedPrintWriter(s));
    1.89 -//    }
    1.90 -//
    1.91 +    /**
    1.92 +     * Prints this throwable and its backtrace to the specified print stream.
    1.93 +     *
    1.94 +     * @param s {@code PrintStream} to use for output
    1.95 +     */
    1.96 +    public void printStackTrace(PrintStream s) {
    1.97 +        s.print(getClass().getName());
    1.98 +        s.print(": ");
    1.99 +        s.println(getMessage());
   1.100 +    }
   1.101 +
   1.102 +    /**
   1.103 +     * Prints this throwable and its backtrace to the specified
   1.104 +     * print writer.
   1.105 +     *
   1.106 +     * @param s {@code PrintWriter} to use for output
   1.107 +     * @since   JDK1.1
   1.108 +     */
   1.109 +    public void printStackTrace(PrintWriter s) {
   1.110 +        s.append(getClass().getName()).append(": ").println(getMessage());
   1.111 +    }
   1.112 +
   1.113  //    /**
   1.114  //     * Wrapper class for PrintStream and PrintWriter to enable a single
   1.115  //     * implementation of printStackTrace.