author | never |
Mon, 12 Jul 2010 22:27:18 -0700 | |
changeset 5926 | a36f90d986b6 |
parent 5506 | 202f599c92aa |
child 5776 | 5f48622225ab |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 2000, 2008, 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 |
|
37 |
* <i>expression</i> (as defined in <a |
|
38 |
* href="http://java.sun.com/docs/books/jls/second_edition/html/j.title.doc.html"> |
|
39 |
* <i>The Java Language Specification, Second Edition</i></a>, |
|
40 |
* <a href="http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#40220"> |
|
41 |
* Section 15.18.1.1</a>), regardless of the type of <i>expression</i>. |
|
42 |
* |
|
43 |
* @since 1.4 |
|
44 |
*/ |
|
45 |
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
|
46 |
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
|
47 |
|
2 | 48 |
/** |
49 |
* Constructs an AssertionError with no detail message. |
|
50 |
*/ |
|
51 |
public AssertionError() { |
|
52 |
} |
|
53 |
||
54 |
/** |
|
55 |
* This internal constructor does no processing on its string argument, |
|
56 |
* even if it is a null reference. The public constructors will |
|
57 |
* never call this constructor with a null argument. |
|
58 |
*/ |
|
59 |
private AssertionError(String detailMessage) { |
|
60 |
super(detailMessage); |
|
61 |
} |
|
62 |
||
63 |
/** |
|
64 |
* Constructs an AssertionError with its detail message derived |
|
65 |
* from the specified object, which is converted to a string as |
|
66 |
* defined in <i>The Java Language Specification, Second |
|
67 |
* Edition</i>, Section 15.18.1.1. |
|
68 |
*<p> |
|
69 |
* If the specified object is an instance of <tt>Throwable</tt>, it |
|
70 |
* becomes the <i>cause</i> of the newly constructed assertion error. |
|
71 |
* |
|
72 |
* @param detailMessage value to be used in constructing detail message |
|
73 |
* @see Throwable#getCause() |
|
74 |
*/ |
|
75 |
public AssertionError(Object detailMessage) { |
|
76 |
this("" + detailMessage); |
|
77 |
if (detailMessage instanceof Throwable) |
|
78 |
initCause((Throwable) detailMessage); |
|
79 |
} |
|
80 |
||
81 |
/** |
|
82 |
* Constructs an AssertionError with its detail message derived |
|
83 |
* from the specified <code>boolean</code>, which is converted to |
|
84 |
* a string as defined in <i>The Java Language Specification, |
|
85 |
* Second Edition</i>, Section 15.18.1.1. |
|
86 |
* |
|
87 |
* @param detailMessage value to be used in constructing detail message |
|
88 |
*/ |
|
89 |
public AssertionError(boolean detailMessage) { |
|
90 |
this("" + detailMessage); |
|
91 |
} |
|
92 |
||
93 |
/** |
|
94 |
* Constructs an AssertionError with its detail message derived |
|
95 |
* from the specified <code>char</code>, which is converted to a |
|
96 |
* string as defined in <i>The Java Language Specification, Second |
|
97 |
* Edition</i>, Section 15.18.1.1. |
|
98 |
* |
|
99 |
* @param detailMessage value to be used in constructing detail message |
|
100 |
*/ |
|
101 |
public AssertionError(char detailMessage) { |
|
102 |
this("" + detailMessage); |
|
103 |
} |
|
104 |
||
105 |
/** |
|
106 |
* Constructs an AssertionError with its detail message derived |
|
107 |
* from the specified <code>int</code>, which is converted to a |
|
108 |
* string as defined in <i>The Java Language Specification, Second |
|
109 |
* Edition</i>, Section 15.18.1.1. |
|
110 |
* |
|
111 |
* @param detailMessage value to be used in constructing detail message |
|
112 |
*/ |
|
113 |
public AssertionError(int detailMessage) { |
|
114 |
this("" + detailMessage); |
|
115 |
} |
|
116 |
||
117 |
/** |
|
118 |
* Constructs an AssertionError with its detail message derived |
|
119 |
* from the specified <code>long</code>, which is converted to a |
|
120 |
* string as defined in <i>The Java Language Specification, Second |
|
121 |
* Edition</i>, Section 15.18.1.1. |
|
122 |
* |
|
123 |
* @param detailMessage value to be used in constructing detail message |
|
124 |
*/ |
|
125 |
public AssertionError(long detailMessage) { |
|
126 |
this("" + detailMessage); |
|
127 |
} |
|
128 |
||
129 |
/** |
|
130 |
* Constructs an AssertionError with its detail message derived |
|
131 |
* from the specified <code>float</code>, which is converted to a |
|
132 |
* string as defined in <i>The Java Language Specification, Second |
|
133 |
* Edition</i>, Section 15.18.1.1. |
|
134 |
* |
|
135 |
* @param detailMessage value to be used in constructing detail message |
|
136 |
*/ |
|
137 |
public AssertionError(float detailMessage) { |
|
138 |
this("" + detailMessage); |
|
139 |
} |
|
140 |
||
141 |
/** |
|
142 |
* Constructs an AssertionError with its detail message derived |
|
143 |
* from the specified <code>double</code>, which is converted to a |
|
144 |
* string as defined in <i>The Java Language Specification, Second |
|
145 |
* Edition</i>, Section 15.18.1.1. |
|
146 |
* |
|
147 |
* @param detailMessage value to be used in constructing detail message |
|
148 |
*/ |
|
149 |
public AssertionError(double detailMessage) { |
|
150 |
this("" + detailMessage); |
|
151 |
} |
|
152 |
} |