test/java/lang/Throwable/SuppressedExceptions.java

Print this page




 187         t0 = t.getSuppressed();
 188         if (t0.length != 0)
 189             throw new RuntimeException("Bad nonzero length of suppressed exceptions.");
 190 
 191         Throwable suppressed = new ArithmeticException();
 192         t = new NoSuppression(true); // Suppression enabled
 193         // Make sure addSuppressed(null) throws an NPE
 194         try {
 195             t.addSuppressed(null);
 196         } catch(NullPointerException e) {
 197             ; // Expected
 198         }
 199         t.addSuppressed(suppressed);
 200         t0 = t.getSuppressed();
 201         if (t0.length != 1 || t0[0] != suppressed)
 202             throw new RuntimeException("Expected suppression did not occur.");
 203     }
 204 
 205     private static class NoSuppression extends Throwable {
 206         public NoSuppression(boolean enableSuppression) {
 207             super("The medium.", null, enableSuppression);
 208         }
 209     }
 210 }


 187         t0 = t.getSuppressed();
 188         if (t0.length != 0)
 189             throw new RuntimeException("Bad nonzero length of suppressed exceptions.");
 190 
 191         Throwable suppressed = new ArithmeticException();
 192         t = new NoSuppression(true); // Suppression enabled
 193         // Make sure addSuppressed(null) throws an NPE
 194         try {
 195             t.addSuppressed(null);
 196         } catch(NullPointerException e) {
 197             ; // Expected
 198         }
 199         t.addSuppressed(suppressed);
 200         t0 = t.getSuppressed();
 201         if (t0.length != 1 || t0[0] != suppressed)
 202             throw new RuntimeException("Expected suppression did not occur.");
 203     }
 204 
 205     private static class NoSuppression extends Throwable {
 206         public NoSuppression(boolean enableSuppression) {
 207             super("The medium.", null, enableSuppression, true);
 208         }
 209     }
 210 }