author | simonis |
Fri, 14 Aug 2015 10:35:45 +0200 | |
changeset 32209 | 24bb680a1609 |
parent 25859 | 3317bb8137f4 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
14342
8435a30053c1
7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents:
11016
diff
changeset
|
2 |
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package java.lang; |
|
27 |
||
28 |
/** |
|
29 |
* Thrown to indicate that an assertion has failed. |
|
30 |
* |
|
31 |
* <p>The seven one-argument public constructors provided by this |
|
32 |
* class ensure that the assertion error returned by the invocation: |
|
33 |
* <pre> |
|
34 |
* new AssertionError(<i>expression</i>) |
|
35 |
* </pre> |
|
36 |
* has as its detail message the <i>string conversion</i> of |
|
9266
121fb370f179
7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents:
7668
diff
changeset
|
37 |
* <i>expression</i> (as defined in section 15.18.1.1 of |
121fb370f179
7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents:
7668
diff
changeset
|
38 |
* <cite>The Java™ Language Specification</cite>), |
121fb370f179
7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents:
7668
diff
changeset
|
39 |
* regardless of the type of <i>expression</i>. |
2 | 40 |
* |
41 |
* @since 1.4 |
|
42 |
*/ |
|
43 |
public class AssertionError extends Error { |
|
1320
2412b1562801
6749308: java.io, java.lang, java.util exception classes don't specify serialVersionUID
chegar
parents:
2
diff
changeset
|
44 |
private static final long serialVersionUID = -5013299493970297370L; |
2412b1562801
6749308: java.io, java.lang, java.util exception classes don't specify serialVersionUID
chegar
parents:
2
diff
changeset
|
45 |
|
2 | 46 |
/** |
47 |
* Constructs an AssertionError with no detail message. |
|
48 |
*/ |
|
49 |
public AssertionError() { |
|
50 |
} |
|
51 |
||
52 |
/** |
|
53 |
* This internal constructor does no processing on its string argument, |
|
54 |
* even if it is a null reference. The public constructors will |
|
55 |
* never call this constructor with a null argument. |
|
56 |
*/ |
|
57 |
private AssertionError(String detailMessage) { |
|
58 |
super(detailMessage); |
|
59 |
} |
|
60 |
||
61 |
/** |
|
62 |
* Constructs an AssertionError with its detail message derived |
|
63 |
* from the specified object, which is converted to a string as |
|
9266
121fb370f179
7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents:
7668
diff
changeset
|
64 |
* defined in section 15.18.1.1 of |
121fb370f179
7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents:
7668
diff
changeset
|
65 |
* <cite>The Java™ Language Specification</cite>. |
2 | 66 |
*<p> |
5776
5f48622225ab
6935997: Please add a nested throwable constructor to AssertionError
darcy
parents:
5506
diff
changeset
|
67 |
* If the specified object is an instance of {@code Throwable}, it |
2 | 68 |
* becomes the <i>cause</i> of the newly constructed assertion error. |
69 |
* |
|
70 |
* @param detailMessage value to be used in constructing detail message |
|
71 |
* @see Throwable#getCause() |
|
72 |
*/ |
|
73 |
public AssertionError(Object detailMessage) { |
|
11016
e2665f4ac6d2
7110111: Minor Java SE javadoc & Constructor clean up
lancea
parents:
9266
diff
changeset
|
74 |
this(String.valueOf(detailMessage)); |
2 | 75 |
if (detailMessage instanceof Throwable) |
76 |
initCause((Throwable) detailMessage); |
|
77 |
} |
|
78 |
||
79 |
/** |
|
80 |
* Constructs an AssertionError with its detail message derived |
|
81 |
* from the specified <code>boolean</code>, which is converted to |
|
9266
121fb370f179
7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents:
7668
diff
changeset
|
82 |
* a string as defined in section 15.18.1.1 of |
121fb370f179
7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents:
7668
diff
changeset
|
83 |
* <cite>The Java™ Language Specification</cite>. |
2 | 84 |
* |
85 |
* @param detailMessage value to be used in constructing detail message |
|
86 |
*/ |
|
87 |
public AssertionError(boolean detailMessage) { |
|
11016
e2665f4ac6d2
7110111: Minor Java SE javadoc & Constructor clean up
lancea
parents:
9266
diff
changeset
|
88 |
this(String.valueOf(detailMessage)); |
2 | 89 |
} |
90 |
||
91 |
/** |
|
92 |
* Constructs an AssertionError with its detail message derived |
|
93 |
* from the specified <code>char</code>, which is converted to a |
|
9266
121fb370f179
7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents:
7668
diff
changeset
|
94 |
* string as defined in section 15.18.1.1 of |
121fb370f179
7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents:
7668
diff
changeset
|
95 |
* <cite>The Java™ Language Specification</cite>. |
2 | 96 |
* |
97 |
* @param detailMessage value to be used in constructing detail message |
|
98 |
*/ |
|
99 |
public AssertionError(char detailMessage) { |
|
11016
e2665f4ac6d2
7110111: Minor Java SE javadoc & Constructor clean up
lancea
parents:
9266
diff
changeset
|
100 |
this(String.valueOf(detailMessage)); |
2 | 101 |
} |
102 |
||
103 |
/** |
|
104 |
* Constructs an AssertionError with its detail message derived |
|
105 |
* from the specified <code>int</code>, which is converted to a |
|
9266
121fb370f179
7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents:
7668
diff
changeset
|
106 |
* string as defined in section 15.18.1.1 of |
121fb370f179
7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents:
7668
diff
changeset
|
107 |
* <cite>The Java™ Language Specification</cite>. |
2 | 108 |
* |
109 |
* @param detailMessage value to be used in constructing detail message |
|
110 |
*/ |
|
111 |
public AssertionError(int detailMessage) { |
|
11016
e2665f4ac6d2
7110111: Minor Java SE javadoc & Constructor clean up
lancea
parents:
9266
diff
changeset
|
112 |
this(String.valueOf(detailMessage)); |
2 | 113 |
} |
114 |
||
115 |
/** |
|
116 |
* Constructs an AssertionError with its detail message derived |
|
117 |
* from the specified <code>long</code>, which is converted to a |
|
9266
121fb370f179
7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents:
7668
diff
changeset
|
118 |
* string as defined in section 15.18.1.1 of |
121fb370f179
7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents:
7668
diff
changeset
|
119 |
* <cite>The Java™ Language Specification</cite>. |
2 | 120 |
* |
121 |
* @param detailMessage value to be used in constructing detail message |
|
122 |
*/ |
|
123 |
public AssertionError(long detailMessage) { |
|
11016
e2665f4ac6d2
7110111: Minor Java SE javadoc & Constructor clean up
lancea
parents:
9266
diff
changeset
|
124 |
this(String.valueOf(detailMessage)); |
2 | 125 |
} |
126 |
||
127 |
/** |
|
128 |
* Constructs an AssertionError with its detail message derived |
|
129 |
* from the specified <code>float</code>, which is converted to a |
|
9266
121fb370f179
7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents:
7668
diff
changeset
|
130 |
* string as defined in section 15.18.1.1 of |
121fb370f179
7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents:
7668
diff
changeset
|
131 |
* <cite>The Java™ Language Specification</cite>. |
2 | 132 |
* |
133 |
* @param detailMessage value to be used in constructing detail message |
|
134 |
*/ |
|
135 |
public AssertionError(float detailMessage) { |
|
11016
e2665f4ac6d2
7110111: Minor Java SE javadoc & Constructor clean up
lancea
parents:
9266
diff
changeset
|
136 |
this(String.valueOf(detailMessage)); |
2 | 137 |
} |
138 |
||
139 |
/** |
|
140 |
* Constructs an AssertionError with its detail message derived |
|
141 |
* from the specified <code>double</code>, which is converted to a |
|
9266
121fb370f179
7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents:
7668
diff
changeset
|
142 |
* string as defined in section 15.18.1.1 of |
121fb370f179
7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents:
7668
diff
changeset
|
143 |
* <cite>The Java™ Language Specification</cite>. |
2 | 144 |
* |
145 |
* @param detailMessage value to be used in constructing detail message |
|
146 |
*/ |
|
147 |
public AssertionError(double detailMessage) { |
|
11016
e2665f4ac6d2
7110111: Minor Java SE javadoc & Constructor clean up
lancea
parents:
9266
diff
changeset
|
148 |
this(String.valueOf(detailMessage)); |
2 | 149 |
} |
5776
5f48622225ab
6935997: Please add a nested throwable constructor to AssertionError
darcy
parents:
5506
diff
changeset
|
150 |
|
5f48622225ab
6935997: Please add a nested throwable constructor to AssertionError
darcy
parents:
5506
diff
changeset
|
151 |
/** |
5f48622225ab
6935997: Please add a nested throwable constructor to AssertionError
darcy
parents:
5506
diff
changeset
|
152 |
* Constructs a new {@code AssertionError} with the specified |
5f48622225ab
6935997: Please add a nested throwable constructor to AssertionError
darcy
parents:
5506
diff
changeset
|
153 |
* detail message and cause. |
5f48622225ab
6935997: Please add a nested throwable constructor to AssertionError
darcy
parents:
5506
diff
changeset
|
154 |
* |
5f48622225ab
6935997: Please add a nested throwable constructor to AssertionError
darcy
parents:
5506
diff
changeset
|
155 |
* <p>Note that the detail message associated with |
5f48622225ab
6935997: Please add a nested throwable constructor to AssertionError
darcy
parents:
5506
diff
changeset
|
156 |
* {@code cause} is <i>not</i> automatically incorporated in |
5f48622225ab
6935997: Please add a nested throwable constructor to AssertionError
darcy
parents:
5506
diff
changeset
|
157 |
* this error's detail message. |
5f48622225ab
6935997: Please add a nested throwable constructor to AssertionError
darcy
parents:
5506
diff
changeset
|
158 |
* |
5f48622225ab
6935997: Please add a nested throwable constructor to AssertionError
darcy
parents:
5506
diff
changeset
|
159 |
* @param message the detail message, may be {@code null} |
5f48622225ab
6935997: Please add a nested throwable constructor to AssertionError
darcy
parents:
5506
diff
changeset
|
160 |
* @param cause the cause, may be {@code null} |
5f48622225ab
6935997: Please add a nested throwable constructor to AssertionError
darcy
parents:
5506
diff
changeset
|
161 |
* |
5f48622225ab
6935997: Please add a nested throwable constructor to AssertionError
darcy
parents:
5506
diff
changeset
|
162 |
* @since 1.7 |
5f48622225ab
6935997: Please add a nested throwable constructor to AssertionError
darcy
parents:
5506
diff
changeset
|
163 |
*/ |
5f48622225ab
6935997: Please add a nested throwable constructor to AssertionError
darcy
parents:
5506
diff
changeset
|
164 |
public AssertionError(String message, Throwable cause) { |
5f48622225ab
6935997: Please add a nested throwable constructor to AssertionError
darcy
parents:
5506
diff
changeset
|
165 |
super(message, cause); |
5f48622225ab
6935997: Please add a nested throwable constructor to AssertionError
darcy
parents:
5506
diff
changeset
|
166 |
} |
2 | 167 |
} |