--- old/src/share/classes/java/lang/Throwable.java 2011-03-29 11:07:40.000000000 -0700 +++ new/src/share/classes/java/lang/Throwable.java 2011-03-29 11:07:40.000000000 -0700 @@ -283,6 +283,38 @@ } /** + * Constructs a new throwable with the specified detail message, + * cause, and {@linkplain #addSuppressed suppression} enabled or + * disabled. If suppression is disabled, {@link #getSuppressed} + * for this object will return a zero-length array and calls to + * {@link #addSuppressed} that would otherwise append an exception + * to the suppressed list will have no effect. + * + *
Note that the other constructors of {@code Throwable} behave + * as if suppression where enabled. Subclasses of {@code + * Throwable} should document any conditions under which + * suppression is disabled. Disabling of suppression should only + * occur in exceptional circumstances where special requirements + * exist, such as a virtual machine reusing exception objects + * under low-memory situations. + * + * @param message the detail message. + * @param cause the cause. (A {@code null} value is permitted, + * and indicates that the cause is nonexistent or unknown.) + * @param enableSuppression whether or not suppression is enabled or disabled + * + * @since 1.7 + */ + protected Throwable(String message, Throwable cause, + boolean enableSuppression) { + fillInStackTrace(); + detailMessage = message; + this.cause = cause; + if (!enableSuppression) + suppressedExceptions = null; + } + + /** * Returns the detail message string of this throwable. * * @return the detail message string of this {@code Throwable} instance @@ -830,13 +862,9 @@ * typically called (automatically and implicitly) by the {@code * try}-with-resources statement. * - * If the first exception to be suppressed is {@code null}, that - * indicates suppressed exception information will not be - * recorded for this exception. Subsequent calls to this method - * will not record any suppressed exceptions. Otherwise, - * attempting to suppress {@code null} after an exception has - * already been successfully suppressed results in a {@code - * NullPointerException}. + *
The suppression behavior is enabled unless disabled + * {@linkplain #Throwable(String, Throwable, boolean) via a + * constructor}. * *
Note that when one exception {@linkplain * #initCause(Throwable) causes} another exception, the first @@ -874,8 +902,7 @@ * suppressed exceptions * @throws IllegalArgumentException if {@code exception} is this * throwable; a throwable cannot suppress itself. - * @throws NullPointerException if {@code exception} is null and - * an exception has already been suppressed by this exception + * @throws NullPointerException if {@code exception} is {@code null} * @since 1.7 */ public final synchronized void addSuppressed(Throwable exception) { @@ -883,11 +910,7 @@ throw new IllegalArgumentException(SELF_SUPPRESSION_MESSAGE); if (exception == null) { - if (suppressedExceptions == SUPPRESSED_SENTINEL) { - suppressedExceptions = null; // No suppression information recorded - return; - } else - throw new NullPointerException(NULL_CAUSE_MESSAGE); + throw new NullPointerException(NULL_CAUSE_MESSAGE); } else { assert exception != null && exception != this;