src/java.base/share/classes/java/lang/Throwable.java
changeset 54059 1bc8513104f2
parent 53947 8e069f7b4fab
child 55526 1de28d191f9c
child 55709 ce3598fceb87
child 58678 9cf78a70fa4f
--- a/src/java.base/share/classes/java/lang/Throwable.java	Mon Mar 11 14:06:05 2019 -0400
+++ b/src/java.base/share/classes/java/lang/Throwable.java	Mon Mar 11 11:23:09 2019 -0700
@@ -914,8 +914,7 @@
                 for (Throwable t : suppressedExceptions) {
                     // Enforce constraints on suppressed exceptions in
                     // case of corrupt or malicious stream.
-                    if (t == null)
-                        throw new NullPointerException(NULL_CAUSE_MESSAGE);
+                    Objects.requireNonNull(t, NULL_CAUSE_MESSAGE);
                     if (t == this)
                         throw new IllegalArgumentException(SELF_SUPPRESSION_MESSAGE);
                     suppressed.add(t);
@@ -942,8 +941,7 @@
                 stackTrace = null;
             } else { // Verify stack trace elements are non-null.
                 for(StackTraceElement ste : stackTrace) {
-                    if (ste == null)
-                        throw new NullPointerException("null StackTraceElement in serial stream. ");
+                    Objects.requireNonNull(ste, "null StackTraceElement in serial stream.");
                 }
             }
         } else {
@@ -1034,8 +1032,7 @@
         if (exception == this)
             throw new IllegalArgumentException(SELF_SUPPRESSION_MESSAGE, exception);
 
-        if (exception == null)
-            throw new NullPointerException(NULL_CAUSE_MESSAGE);
+        Objects.requireNonNull(exception, NULL_CAUSE_MESSAGE);
 
         if (suppressedExceptions == null) // Suppressed exceptions not recorded
             return;