--- old/test/java/lang/Throwable/SuppressedExceptions.java 2013-04-15 17:55:37.000000000 -0700 +++ new/test/java/lang/Throwable/SuppressedExceptions.java 2013-04-15 17:55:37.000000000 -0700 @@ -26,7 +26,7 @@ /* * @test - * @bug 6911258 6962571 6963622 6991528 7005628 + * @bug 6911258 6962571 6963622 6991528 7005628 8012044 * @summary Basic tests of suppressed exceptions * @author Joseph D. Darcy */ @@ -40,6 +40,7 @@ serializationTest(); selfReference(); noModification(); + initCausePlumbing(); } private static void noSelfSuppression() { @@ -48,7 +49,9 @@ throwable.addSuppressed(throwable); throw new RuntimeException("IllegalArgumentException for self-suppresion not thrown."); } catch (IllegalArgumentException iae) { - ; // Expected + // Expected to be here + if (iae.getCause() != throwable) + throw new RuntimeException("Bad cause after self-suppresion."); } } @@ -208,4 +211,36 @@ super("The medium.", null, enableSuppression, true); } } + + private static void initCausePlumbing() { + Throwable t1 = new Throwable(); + Throwable t2 = new Throwable("message", t1); + Throwable t3 = new Throwable(); + + try { + t2.initCause(t3); + throw new RuntimeException("Shouldn't reach."); + } catch (IllegalStateException ise) { + if (ise.getCause() != null) + throw new RuntimeException("Unexpected cause in ISE", ise); + Throwable[] suppressed = ise.getSuppressed(); + if (suppressed.length != 2 || suppressed[0] != t2 || suppressed[1] != t3) + throw new RuntimeException("Bad suppression in ISE", ise); + } + + try { + t2.initCause(null); + throw new RuntimeException("Shouldn't reach."); + } catch (IllegalStateException ise) { + ; // Expected; don't want an NPE. + } + + try { + t3.initCause(t3); + throw new RuntimeException("Shouldn't reach."); + } catch (IllegalArgumentException iae) { + if (iae.getCause() != t3) + throw new RuntimeException("Unexpected cause in ISE", iae); + } + } }