From 82b4353a8f0365cc1d0e0fdd3469902c7571a466 Mon Sep 17 00:00:00 2001 From: darcy Date: Tue, 8 Jun 2010 18:52:17 -0700 Subject: [PATCH] 6935997: Please add a nested throwable constructor to AssertionError Reviewed-by: martin, forax, wetmore --- .../classes/java/lang/AssertionError.java | 19 ++++++++++++++++++- src/share/classes/java/security/Security.java | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/share/classes/java/lang/AssertionError.java b/src/share/classes/java/lang/AssertionError.java index 75e8cd8f0..8fb577a6e 100644 --- a/src/share/classes/java/lang/AssertionError.java +++ b/src/share/classes/java/lang/AssertionError.java @@ -66,7 +66,7 @@ public class AssertionError extends Error { * defined in The Java Language Specification, Second * Edition, Section 15.18.1.1. *

- * If the specified object is an instance of Throwable, it + * If the specified object is an instance of {@code Throwable}, it * becomes the cause of the newly constructed assertion error. * * @param detailMessage value to be used in constructing detail message @@ -149,4 +149,21 @@ public class AssertionError extends Error { public AssertionError(double detailMessage) { this("" + detailMessage); } + + /** + * Constructs a new {@code AssertionError} with the specified + * detail message and cause. + * + *

Note that the detail message associated with + * {@code cause} is not 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); + } } diff --git a/src/share/classes/java/security/Security.java b/src/share/classes/java/security/Security.java index 4aea17e38..81e029b8e 100644 --- a/src/share/classes/java/security/Security.java +++ b/src/share/classes/java/security/Security.java @@ -678,7 +678,7 @@ public final class Security { 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); } } -- GitLab