New protocol for disabling exception suppression

Neal Gafter neal at
Sun Apr 3 08:43:35 PDT 2011

The mechanism for adding suppressed exceptions does not appear to be
thread-safe.  Since this introduces a way in which exceptions used to
be thread-safe but no longer are thread-safe, this might require
significant nonlocal refactoring of existing code in order to use the
new try-with-resources statement.

On Friday, April 1, 2011,  <joe.darcy at> wrote:
> As part of the library support for the try-with-resources statement,
> several API changes were made to Throwable including an addSuppressed
> method to allow suppressed exceptions to be recorded. As previously
> discussed on coin-dev [1], to support VM needs for reusable exception
> objects, a protocol was devised to disable the suppression mechanism so
> that a zero-length array would be returned from getSuppressed even if
> addSuppressed was called with a valid argument. The mechanism was a bit
> of a kludge, relying on an initial call to addSuppressed with a null
> argument, and the design was called out as such. [2] I'm happy to report
> the JSR 334 expert group has devised a more elegant protocol to disable
> exception suppression: a new constructor is added to Throwable which
> supports disabling suppression. The existing constructors of Throwable
> always enable suppression and addSuppressed(null) now always throws a
> NullPointerException. A few exception and error types in the platform
> are allowed by behave as if their objects were created with suppression
> disabled.
> The fix was recently pushed [3] and will appear in a future JDK 7 build.
> -Joe
> [1]
> [2]
> [3]

More information about the coin-dev mailing list