src/java.base/share/classes/java/lang/AssertionError.java
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58288 48e480e56aad
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
57956
e0b8b019d2f5 8229997: Apply java.io.Serial annotations in java.base
darcy
parents: 47216
diff changeset
     2
 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
2
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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1320
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1320
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1320
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1320
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1320
diff changeset
    23
 * questions.
2
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
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&trade; 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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * @since   1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
public class AssertionError extends Error {
57956
e0b8b019d2f5 8229997: Apply java.io.Serial annotations in java.base
darcy
parents: 47216
diff changeset
    44
    @java.io.Serial
1320
2412b1562801 6749308: java.io, java.lang, java.util exception classes don't specify serialVersionUID
chegar
parents: 2
diff changeset
    45
    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
    46
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * Constructs an AssertionError with no detail message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    public AssertionError() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * This internal constructor does no processing on its string argument,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * even if it is a null reference.  The public constructors will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * never call this constructor with a null argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    private AssertionError(String detailMessage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        super(detailMessage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * Constructs an AssertionError with its detail message derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * 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
    65
     * 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
    66
     * <cite>The Java&trade; Language Specification</cite>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     *<p>
5776
5f48622225ab 6935997: Please add a nested throwable constructor to AssertionError
darcy
parents: 5506
diff changeset
    68
     * If the specified object is an instance of {@code Throwable}, it
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * becomes the <i>cause</i> of the newly constructed assertion error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * @param detailMessage value to be used in constructing detail message
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * @see   Throwable#getCause()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    public AssertionError(Object detailMessage) {
11016
e2665f4ac6d2 7110111: Minor Java SE javadoc & Constructor clean up
lancea
parents: 9266
diff changeset
    75
        this(String.valueOf(detailMessage));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        if (detailMessage instanceof Throwable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            initCause((Throwable) detailMessage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * Constructs an AssertionError with its detail message derived
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 57956
diff changeset
    82
     * from the specified {@code boolean}, 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
    83
     * 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
    84
     * <cite>The Java&trade; Language Specification</cite>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * @param detailMessage value to be used in constructing detail message
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    public AssertionError(boolean detailMessage) {
11016
e2665f4ac6d2 7110111: Minor Java SE javadoc & Constructor clean up
lancea
parents: 9266
diff changeset
    89
        this(String.valueOf(detailMessage));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * Constructs an AssertionError with its detail message derived
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 57956
diff changeset
    94
     * from the specified {@code char}, 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
    95
     * 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
    96
     * <cite>The Java&trade; Language Specification</cite>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @param detailMessage value to be used in constructing detail message
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    public AssertionError(char detailMessage) {
11016
e2665f4ac6d2 7110111: Minor Java SE javadoc & Constructor clean up
lancea
parents: 9266
diff changeset
   101
        this(String.valueOf(detailMessage));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * Constructs an AssertionError with its detail message derived
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 57956
diff changeset
   106
     * from the specified {@code int}, 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
   107
     * 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
   108
     * <cite>The Java&trade; Language Specification</cite>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @param detailMessage value to be used in constructing detail message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    public AssertionError(int detailMessage) {
11016
e2665f4ac6d2 7110111: Minor Java SE javadoc & Constructor clean up
lancea
parents: 9266
diff changeset
   113
        this(String.valueOf(detailMessage));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * Constructs an AssertionError with its detail message derived
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 57956
diff changeset
   118
     * from the specified {@code long}, 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
   119
     * 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
   120
     * <cite>The Java&trade; Language Specification</cite>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @param detailMessage value to be used in constructing detail message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public AssertionError(long detailMessage) {
11016
e2665f4ac6d2 7110111: Minor Java SE javadoc & Constructor clean up
lancea
parents: 9266
diff changeset
   125
        this(String.valueOf(detailMessage));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * Constructs an AssertionError with its detail message derived
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 57956
diff changeset
   130
     * from the specified {@code float}, 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
   131
     * 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
   132
     * <cite>The Java&trade; Language Specification</cite>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @param detailMessage value to be used in constructing detail message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    public AssertionError(float detailMessage) {
11016
e2665f4ac6d2 7110111: Minor Java SE javadoc & Constructor clean up
lancea
parents: 9266
diff changeset
   137
        this(String.valueOf(detailMessage));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * Constructs an AssertionError with its detail message derived
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 57956
diff changeset
   142
     * from the specified {@code double}, 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
   143
     * 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
   144
     * <cite>The Java&trade; Language Specification</cite>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @param detailMessage value to be used in constructing detail message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    public AssertionError(double detailMessage) {
11016
e2665f4ac6d2 7110111: Minor Java SE javadoc & Constructor clean up
lancea
parents: 9266
diff changeset
   149
        this(String.valueOf(detailMessage));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
5776
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
    /**
5f48622225ab 6935997: Please add a nested throwable constructor to AssertionError
darcy
parents: 5506
diff changeset
   153
     * Constructs a new {@code AssertionError} with the specified
5f48622225ab 6935997: Please add a nested throwable constructor to AssertionError
darcy
parents: 5506
diff changeset
   154
     * detail message and cause.
5f48622225ab 6935997: Please add a nested throwable constructor to AssertionError
darcy
parents: 5506
diff changeset
   155
     *
5f48622225ab 6935997: Please add a nested throwable constructor to AssertionError
darcy
parents: 5506
diff changeset
   156
     * <p>Note that the detail message associated with
5f48622225ab 6935997: Please add a nested throwable constructor to AssertionError
darcy
parents: 5506
diff changeset
   157
     * {@code cause} is <i>not</i> automatically incorporated in
5f48622225ab 6935997: Please add a nested throwable constructor to AssertionError
darcy
parents: 5506
diff changeset
   158
     * this error's detail message.
5f48622225ab 6935997: Please add a nested throwable constructor to AssertionError
darcy
parents: 5506
diff changeset
   159
     *
5f48622225ab 6935997: Please add a nested throwable constructor to AssertionError
darcy
parents: 5506
diff changeset
   160
     * @param  message the detail message, may be {@code null}
5f48622225ab 6935997: Please add a nested throwable constructor to AssertionError
darcy
parents: 5506
diff changeset
   161
     * @param  cause the cause, may be {@code null}
5f48622225ab 6935997: Please add a nested throwable constructor to AssertionError
darcy
parents: 5506
diff changeset
   162
     *
5f48622225ab 6935997: Please add a nested throwable constructor to AssertionError
darcy
parents: 5506
diff changeset
   163
     * @since 1.7
5f48622225ab 6935997: Please add a nested throwable constructor to AssertionError
darcy
parents: 5506
diff changeset
   164
     */
5f48622225ab 6935997: Please add a nested throwable constructor to AssertionError
darcy
parents: 5506
diff changeset
   165
    public AssertionError(String message, Throwable cause) {
5f48622225ab 6935997: Please add a nested throwable constructor to AssertionError
darcy
parents: 5506
diff changeset
   166
        super(message, cause);
5f48622225ab 6935997: Please add a nested throwable constructor to AssertionError
darcy
parents: 5506
diff changeset
   167
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
}