emul/mini/src/main/java/java/lang/AssertionError.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Sat, 26 Jan 2013 08:47:05 +0100
changeset 592 5e13b1ac2886
parent 70 177ce4a56a6d
permissions -rw-r--r--
In order to support fields of the same name in subclasses we are now prefixing them with name of the class that defines them. To provide convenient way to access them from generated bytecode and also directly from JavaScript, there is a getter/setter function for each field. It starts with _ followed by the field name. If called with a parameter, it sets the field, with a parameter it just returns it.
jaroslav@70
     1
/*
jaroslav@70
     2
 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
jaroslav@70
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jaroslav@70
     4
 *
jaroslav@70
     5
 * This code is free software; you can redistribute it and/or modify it
jaroslav@70
     6
 * under the terms of the GNU General Public License version 2 only, as
jaroslav@70
     7
 * published by the Free Software Foundation.  Oracle designates this
jaroslav@70
     8
 * particular file as subject to the "Classpath" exception as provided
jaroslav@70
     9
 * by Oracle in the LICENSE file that accompanied this code.
jaroslav@70
    10
 *
jaroslav@70
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
jaroslav@70
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jaroslav@70
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
jaroslav@70
    14
 * version 2 for more details (a copy is included in the LICENSE file that
jaroslav@70
    15
 * accompanied this code).
jaroslav@70
    16
 *
jaroslav@70
    17
 * You should have received a copy of the GNU General Public License version
jaroslav@70
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
jaroslav@70
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jaroslav@70
    20
 *
jaroslav@70
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jaroslav@70
    22
 * or visit www.oracle.com if you need additional information or have any
jaroslav@70
    23
 * questions.
jaroslav@70
    24
 */
jaroslav@70
    25
jaroslav@70
    26
package java.lang;
jaroslav@70
    27
jaroslav@70
    28
/**
jaroslav@70
    29
 * Thrown to indicate that an assertion has failed.
jaroslav@70
    30
 *
jaroslav@70
    31
 * <p>The seven one-argument public constructors provided by this
jaroslav@70
    32
 * class ensure that the assertion error returned by the invocation:
jaroslav@70
    33
 * <pre>
jaroslav@70
    34
 *     new AssertionError(<i>expression</i>)
jaroslav@70
    35
 * </pre>
jaroslav@70
    36
 * has as its detail message the <i>string conversion</i> of
jaroslav@70
    37
 * <i>expression</i> (as defined in section 15.18.1.1 of
jaroslav@70
    38
 * <cite>The Java&trade; Language Specification</cite>),
jaroslav@70
    39
 * regardless of the type of <i>expression</i>.
jaroslav@70
    40
 *
jaroslav@70
    41
 * @since   1.4
jaroslav@70
    42
 */
jaroslav@70
    43
public class AssertionError extends Error {
jaroslav@70
    44
    private static final long serialVersionUID = -5013299493970297370L;
jaroslav@70
    45
jaroslav@70
    46
    /**
jaroslav@70
    47
     * Constructs an AssertionError with no detail message.
jaroslav@70
    48
     */
jaroslav@70
    49
    public AssertionError() {
jaroslav@70
    50
    }
jaroslav@70
    51
jaroslav@70
    52
    /**
jaroslav@70
    53
     * This internal constructor does no processing on its string argument,
jaroslav@70
    54
     * even if it is a null reference.  The public constructors will
jaroslav@70
    55
     * never call this constructor with a null argument.
jaroslav@70
    56
     */
jaroslav@70
    57
    private AssertionError(String detailMessage) {
jaroslav@70
    58
        super(detailMessage);
jaroslav@70
    59
    }
jaroslav@70
    60
jaroslav@70
    61
    /**
jaroslav@70
    62
     * Constructs an AssertionError with its detail message derived
jaroslav@70
    63
     * from the specified object, which is converted to a string as
jaroslav@70
    64
     * defined in section 15.18.1.1 of
jaroslav@70
    65
     * <cite>The Java&trade; Language Specification</cite>.
jaroslav@70
    66
     *<p>
jaroslav@70
    67
     * If the specified object is an instance of {@code Throwable}, it
jaroslav@70
    68
     * becomes the <i>cause</i> of the newly constructed assertion error.
jaroslav@70
    69
     *
jaroslav@70
    70
     * @param detailMessage value to be used in constructing detail message
jaroslav@70
    71
     * @see   Throwable#getCause()
jaroslav@70
    72
     */
jaroslav@70
    73
    public AssertionError(Object detailMessage) {
jaroslav@70
    74
        this("" +  detailMessage);
jaroslav@70
    75
        if (detailMessage instanceof Throwable)
jaroslav@70
    76
            initCause((Throwable) detailMessage);
jaroslav@70
    77
    }
jaroslav@70
    78
jaroslav@70
    79
    /**
jaroslav@70
    80
     * Constructs an AssertionError with its detail message derived
jaroslav@70
    81
     * from the specified <code>boolean</code>, which is converted to
jaroslav@70
    82
     * a string as defined in section 15.18.1.1 of
jaroslav@70
    83
     * <cite>The Java&trade; Language Specification</cite>.
jaroslav@70
    84
     *
jaroslav@70
    85
     * @param detailMessage value to be used in constructing detail message
jaroslav@70
    86
     */
jaroslav@70
    87
    public AssertionError(boolean detailMessage) {
jaroslav@70
    88
        this("" +  detailMessage);
jaroslav@70
    89
    }
jaroslav@70
    90
jaroslav@70
    91
    /**
jaroslav@70
    92
     * Constructs an AssertionError with its detail message derived
jaroslav@70
    93
     * from the specified <code>char</code>, which is converted to a
jaroslav@70
    94
     * string as defined in section 15.18.1.1 of
jaroslav@70
    95
     * <cite>The Java&trade; Language Specification</cite>.
jaroslav@70
    96
     *
jaroslav@70
    97
     * @param detailMessage value to be used in constructing detail message
jaroslav@70
    98
     */
jaroslav@70
    99
    public AssertionError(char detailMessage) {
jaroslav@70
   100
        this("" +  detailMessage);
jaroslav@70
   101
    }
jaroslav@70
   102
jaroslav@70
   103
    /**
jaroslav@70
   104
     * Constructs an AssertionError with its detail message derived
jaroslav@70
   105
     * from the specified <code>int</code>, which is converted to a
jaroslav@70
   106
     * string as defined in section 15.18.1.1 of
jaroslav@70
   107
     * <cite>The Java&trade; Language Specification</cite>.
jaroslav@70
   108
     *
jaroslav@70
   109
     * @param detailMessage value to be used in constructing detail message
jaroslav@70
   110
     */
jaroslav@70
   111
    public AssertionError(int detailMessage) {
jaroslav@70
   112
        this("" +  detailMessage);
jaroslav@70
   113
    }
jaroslav@70
   114
jaroslav@70
   115
    /**
jaroslav@70
   116
     * Constructs an AssertionError with its detail message derived
jaroslav@70
   117
     * from the specified <code>long</code>, which is converted to a
jaroslav@70
   118
     * string as defined in section 15.18.1.1 of
jaroslav@70
   119
     * <cite>The Java&trade; Language Specification</cite>.
jaroslav@70
   120
     *
jaroslav@70
   121
     * @param detailMessage value to be used in constructing detail message
jaroslav@70
   122
     */
jaroslav@70
   123
    public AssertionError(long detailMessage) {
jaroslav@70
   124
        this("" +  detailMessage);
jaroslav@70
   125
    }
jaroslav@70
   126
jaroslav@70
   127
    /**
jaroslav@70
   128
     * Constructs an AssertionError with its detail message derived
jaroslav@70
   129
     * from the specified <code>float</code>, which is converted to a
jaroslav@70
   130
     * string as defined in section 15.18.1.1 of
jaroslav@70
   131
     * <cite>The Java&trade; Language Specification</cite>.
jaroslav@70
   132
     *
jaroslav@70
   133
     * @param detailMessage value to be used in constructing detail message
jaroslav@70
   134
     */
jaroslav@70
   135
    public AssertionError(float detailMessage) {
jaroslav@70
   136
        this("" +  detailMessage);
jaroslav@70
   137
    }
jaroslav@70
   138
jaroslav@70
   139
    /**
jaroslav@70
   140
     * Constructs an AssertionError with its detail message derived
jaroslav@70
   141
     * from the specified <code>double</code>, which is converted to a
jaroslav@70
   142
     * string as defined in section 15.18.1.1 of
jaroslav@70
   143
     * <cite>The Java&trade; Language Specification</cite>.
jaroslav@70
   144
     *
jaroslav@70
   145
     * @param detailMessage value to be used in constructing detail message
jaroslav@70
   146
     */
jaroslav@70
   147
    public AssertionError(double detailMessage) {
jaroslav@70
   148
        this("" +  detailMessage);
jaroslav@70
   149
    }
jaroslav@70
   150
jaroslav@70
   151
    /**
jaroslav@70
   152
     * Constructs a new {@code AssertionError} with the specified
jaroslav@70
   153
     * detail message and cause.
jaroslav@70
   154
     *
jaroslav@70
   155
     * <p>Note that the detail message associated with
jaroslav@70
   156
     * {@code cause} is <i>not</i> automatically incorporated in
jaroslav@70
   157
     * this error's detail message.
jaroslav@70
   158
     *
jaroslav@70
   159
     * @param  message the detail message, may be {@code null}
jaroslav@70
   160
     * @param  cause the cause, may be {@code null}
jaroslav@70
   161
     *
jaroslav@70
   162
     * @since 1.7
jaroslav@70
   163
     */
jaroslav@70
   164
    public AssertionError(String message, Throwable cause) {
jaroslav@70
   165
        super(message, cause);
jaroslav@70
   166
    }
jaroslav@70
   167
}