changeset 2465:a21e3a29ca9d

6935997: Please add a nested throwable constructor to AssertionError Reviewed-by: martin, forax, wetmore
author darcy
date Tue, 08 Jun 2010 18:52:17 -0700
parents 489c1720757b
children af68ad345389 1474dfa499e3
files src/share/classes/java/lang/AssertionError.java src/share/classes/java/security/Security.java
diffstat 2 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/lang/AssertionError.java	Tue Jun 08 10:46:14 2010 +0100
+++ b/src/share/classes/java/lang/AssertionError.java	Tue Jun 08 18:52:17 2010 -0700
@@ -66,7 +66,7 @@
      * defined in <i>The Java Language Specification, Second
      * Edition</i>, Section 15.18.1.1.
      *<p>
-     * If the specified object is an instance of <tt>Throwable</tt>, it
+     * If the specified object is an instance of {@code Throwable}, it
      * becomes the <i>cause</i> of the newly constructed assertion error.
      *
      * @param detailMessage value to be used in constructing detail message
@@ -149,4 +149,21 @@
     public AssertionError(double detailMessage) {
         this("" +  detailMessage);
     }
+
+    /**
+     * Constructs a new {@code AssertionError} with the specified
+     * detail message and cause.
+     *
+     * <p>Note that the detail message associated with
+     * {@code cause} is <i>not</i> automatically incorporated in
+     * this error's detail message.
+     *
+     * @param  message the detail message, may be {@code null}
+     * @param  cause the cause, may be {@code null}
+     *
+     * @since 1.7
+     */
+    public AssertionError(String message, Throwable cause) {
+        super(message, cause);
+    }
 }
--- a/src/share/classes/java/security/Security.java	Tue Jun 08 10:46:14 2010 +0100
+++ b/src/share/classes/java/security/Security.java	Tue Jun 08 18:52:17 2010 -0700
@@ -678,7 +678,7 @@
             spiMap.put(type, clazz);
             return clazz;
         } catch (ClassNotFoundException e) {
-            throw (Error)new AssertionError("Spi class not found").initCause(e);
+            throw new AssertionError("Spi class not found", e);
         }
     }