test/java/lang/Throwable/SuppressedExceptions.java
Print this page
*** 33,47 ****
--- 33,58 ----
public class SuppressedExceptions {
private static String message = "Bad suppressed exception information";
public static void main(String... args) throws Exception {
+ noSelfSuppression();
basicSupressionTest();
serializationTest();
selfReference();
}
+ private static void noSelfSuppression() {
+ Throwable throwable = new Throwable();
+ try {
+ throwable.addSuppressedException(throwable);
+ throw new RuntimeException("IllegalArgumentException for self-suppresion not thrown.");
+ } catch (IllegalArgumentException iae) {
+ ; // Expected
+ }
+ }
+
private static void basicSupressionTest() {
Throwable throwable = new Throwable();
RuntimeException suppressed = new RuntimeException("A suppressed exception.");
AssertionError repressed = new AssertionError("A repressed error.");
*** 154,165 ****
throwable1.initCause(throwable2);
throwable2.initCause(throwable1);
throwable1.printStackTrace();
-
- throwable1.addSuppressedException(throwable1);
throwable1.addSuppressedException(throwable2);
throwable1.printStackTrace();
}
}
--- 165,175 ----
throwable1.initCause(throwable2);
throwable2.initCause(throwable1);
throwable1.printStackTrace();
throwable1.addSuppressedException(throwable2);
+ throwable2.addSuppressedException(throwable1);
throwable1.printStackTrace();
}
}