rt/emul/mini/src/main/java/java/lang/AssertionError.java
changeset 772 d382dacfd73f
parent 554 05224402145d
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/rt/emul/mini/src/main/java/java/lang/AssertionError.java	Tue Feb 26 16:54:16 2013 +0100
     1.3 @@ -0,0 +1,167 @@
     1.4 +/*
     1.5 + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package java.lang;
    1.30 +
    1.31 +/**
    1.32 + * Thrown to indicate that an assertion has failed.
    1.33 + *
    1.34 + * <p>The seven one-argument public constructors provided by this
    1.35 + * class ensure that the assertion error returned by the invocation:
    1.36 + * <pre>
    1.37 + *     new AssertionError(<i>expression</i>)
    1.38 + * </pre>
    1.39 + * has as its detail message the <i>string conversion</i> of
    1.40 + * <i>expression</i> (as defined in section 15.18.1.1 of
    1.41 + * <cite>The Java&trade; Language Specification</cite>),
    1.42 + * regardless of the type of <i>expression</i>.
    1.43 + *
    1.44 + * @since   1.4
    1.45 + */
    1.46 +public class AssertionError extends Error {
    1.47 +    private static final long serialVersionUID = -5013299493970297370L;
    1.48 +
    1.49 +    /**
    1.50 +     * Constructs an AssertionError with no detail message.
    1.51 +     */
    1.52 +    public AssertionError() {
    1.53 +    }
    1.54 +
    1.55 +    /**
    1.56 +     * This internal constructor does no processing on its string argument,
    1.57 +     * even if it is a null reference.  The public constructors will
    1.58 +     * never call this constructor with a null argument.
    1.59 +     */
    1.60 +    private AssertionError(String detailMessage) {
    1.61 +        super(detailMessage);
    1.62 +    }
    1.63 +
    1.64 +    /**
    1.65 +     * Constructs an AssertionError with its detail message derived
    1.66 +     * from the specified object, which is converted to a string as
    1.67 +     * defined in section 15.18.1.1 of
    1.68 +     * <cite>The Java&trade; Language Specification</cite>.
    1.69 +     *<p>
    1.70 +     * If the specified object is an instance of {@code Throwable}, it
    1.71 +     * becomes the <i>cause</i> of the newly constructed assertion error.
    1.72 +     *
    1.73 +     * @param detailMessage value to be used in constructing detail message
    1.74 +     * @see   Throwable#getCause()
    1.75 +     */
    1.76 +    public AssertionError(Object detailMessage) {
    1.77 +        this("" +  detailMessage);
    1.78 +        if (detailMessage instanceof Throwable)
    1.79 +            initCause((Throwable) detailMessage);
    1.80 +    }
    1.81 +
    1.82 +    /**
    1.83 +     * Constructs an AssertionError with its detail message derived
    1.84 +     * from the specified <code>boolean</code>, which is converted to
    1.85 +     * a string as defined in section 15.18.1.1 of
    1.86 +     * <cite>The Java&trade; Language Specification</cite>.
    1.87 +     *
    1.88 +     * @param detailMessage value to be used in constructing detail message
    1.89 +     */
    1.90 +    public AssertionError(boolean detailMessage) {
    1.91 +        this("" +  detailMessage);
    1.92 +    }
    1.93 +
    1.94 +    /**
    1.95 +     * Constructs an AssertionError with its detail message derived
    1.96 +     * from the specified <code>char</code>, which is converted to a
    1.97 +     * string as defined in section 15.18.1.1 of
    1.98 +     * <cite>The Java&trade; Language Specification</cite>.
    1.99 +     *
   1.100 +     * @param detailMessage value to be used in constructing detail message
   1.101 +     */
   1.102 +    public AssertionError(char detailMessage) {
   1.103 +        this("" +  detailMessage);
   1.104 +    }
   1.105 +
   1.106 +    /**
   1.107 +     * Constructs an AssertionError with its detail message derived
   1.108 +     * from the specified <code>int</code>, which is converted to a
   1.109 +     * string as defined in section 15.18.1.1 of
   1.110 +     * <cite>The Java&trade; Language Specification</cite>.
   1.111 +     *
   1.112 +     * @param detailMessage value to be used in constructing detail message
   1.113 +     */
   1.114 +    public AssertionError(int detailMessage) {
   1.115 +        this("" +  detailMessage);
   1.116 +    }
   1.117 +
   1.118 +    /**
   1.119 +     * Constructs an AssertionError with its detail message derived
   1.120 +     * from the specified <code>long</code>, which is converted to a
   1.121 +     * string as defined in section 15.18.1.1 of
   1.122 +     * <cite>The Java&trade; Language Specification</cite>.
   1.123 +     *
   1.124 +     * @param detailMessage value to be used in constructing detail message
   1.125 +     */
   1.126 +    public AssertionError(long detailMessage) {
   1.127 +        this("" +  detailMessage);
   1.128 +    }
   1.129 +
   1.130 +    /**
   1.131 +     * Constructs an AssertionError with its detail message derived
   1.132 +     * from the specified <code>float</code>, which is converted to a
   1.133 +     * string as defined in section 15.18.1.1 of
   1.134 +     * <cite>The Java&trade; Language Specification</cite>.
   1.135 +     *
   1.136 +     * @param detailMessage value to be used in constructing detail message
   1.137 +     */
   1.138 +    public AssertionError(float detailMessage) {
   1.139 +        this("" +  detailMessage);
   1.140 +    }
   1.141 +
   1.142 +    /**
   1.143 +     * Constructs an AssertionError with its detail message derived
   1.144 +     * from the specified <code>double</code>, which is converted to a
   1.145 +     * string as defined in section 15.18.1.1 of
   1.146 +     * <cite>The Java&trade; Language Specification</cite>.
   1.147 +     *
   1.148 +     * @param detailMessage value to be used in constructing detail message
   1.149 +     */
   1.150 +    public AssertionError(double detailMessage) {
   1.151 +        this("" +  detailMessage);
   1.152 +    }
   1.153 +
   1.154 +    /**
   1.155 +     * Constructs a new {@code AssertionError} with the specified
   1.156 +     * detail message and cause.
   1.157 +     *
   1.158 +     * <p>Note that the detail message associated with
   1.159 +     * {@code cause} is <i>not</i> automatically incorporated in
   1.160 +     * this error's detail message.
   1.161 +     *
   1.162 +     * @param  message the detail message, may be {@code null}
   1.163 +     * @param  cause the cause, may be {@code null}
   1.164 +     *
   1.165 +     * @since 1.7
   1.166 +     */
   1.167 +    public AssertionError(String message, Throwable cause) {
   1.168 +        super(message, cause);
   1.169 +    }
   1.170 +}