jdk/src/share/classes/java/lang/AssertionError.java
author martin
Mon, 10 Mar 2008 14:32:51 -0700
changeset 48 dc5744ca15ea
parent 2 90ce3da70b43
child 1320 2412b1562801
permissions -rw-r--r--
4960438: (process) Need IO redirection API for subprocesses Reviewed-by: alanb, iris
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.lang;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * Thrown to indicate that an assertion has failed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * <p>The seven one-argument public constructors provided by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * class ensure that the assertion error returned by the invocation:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *     new AssertionError(<i>expression</i>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * has as its detail message the <i>string conversion</i> of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <i>expression</i> (as defined in <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * href="http://java.sun.com/docs/books/jls/second_edition/html/j.title.doc.html">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <i>The Java Language Specification, Second Edition</i></a>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <a href="http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#40220">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * Section  15.18.1.1</a>), regardless of the type of <i>expression</i>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @since   1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
public class AssertionError extends Error {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     * Constructs an AssertionError with no detail message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    public AssertionError() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * This internal constructor does no processing on its string argument,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * even if it is a null reference.  The public constructors will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * never call this constructor with a null argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private AssertionError(String detailMessage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        super(detailMessage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * Constructs an AssertionError with its detail message derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * from the specified object, which is converted to a string as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * defined in <i>The Java Language Specification, Second
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * Edition</i>, Section 15.18.1.1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * If the specified object is an instance of <tt>Throwable</tt>, it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * becomes the <i>cause</i> of the newly constructed assertion error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * @param detailMessage value to be used in constructing detail message
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * @see   Throwable#getCause()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    public AssertionError(Object detailMessage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        this("" +  detailMessage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        if (detailMessage instanceof Throwable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            initCause((Throwable) detailMessage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * Constructs an AssertionError with its detail message derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * from the specified <code>boolean</code>, which is converted to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * a string as defined in <i>The Java Language Specification,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * Second Edition</i>, Section 15.18.1.1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * @param detailMessage value to be used in constructing detail message
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    public AssertionError(boolean detailMessage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        this("" +  detailMessage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * Constructs an AssertionError with its detail message derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * from the specified <code>char</code>, which is converted to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * string as defined in <i>The Java Language Specification, Second
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * Edition</i>, Section 15.18.1.1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @param detailMessage value to be used in constructing detail message
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    public AssertionError(char detailMessage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        this("" +  detailMessage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * Constructs an AssertionError with its detail message derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * from the specified <code>int</code>, which is converted to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * string as defined in <i>The Java Language Specification, Second
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * Edition</i>, Section 15.18.1.1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * @param detailMessage value to be used in constructing detail message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    public AssertionError(int detailMessage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        this("" +  detailMessage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * Constructs an AssertionError with its detail message derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * from the specified <code>long</code>, which is converted to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * string as defined in <i>The Java Language Specification, Second
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * Edition</i>, Section 15.18.1.1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @param detailMessage value to be used in constructing detail message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    public AssertionError(long detailMessage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        this("" +  detailMessage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * Constructs an AssertionError with its detail message derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * from the specified <code>float</code>, which is converted to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * string as defined in <i>The Java Language Specification, Second
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * Edition</i>, Section 15.18.1.1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @param detailMessage value to be used in constructing detail message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    public AssertionError(float detailMessage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        this("" +  detailMessage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * Constructs an AssertionError with its detail message derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * from the specified <code>double</code>, which is converted to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * string as defined in <i>The Java Language Specification, Second
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * Edition</i>, Section 15.18.1.1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @param detailMessage value to be used in constructing detail message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    public AssertionError(double detailMessage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        this("" +  detailMessage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
}