Save This Page
Home » openjdk-7 » java » lang » [javadoc | source]
    1   /*
    2    * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
    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
    7    * published by the Free Software Foundation.  Sun designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Sun in the LICENSE file that accompanied this code.
   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    *
   21    * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   22    * CA 95054 USA or visit www.sun.com if you need additional information or
   23    * have any questions.
   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 {
   46       /**
   47        * Constructs an AssertionError with no detail message.
   48        */
   49       public AssertionError() {
   50       }
   51   
   52       /**
   53        * This internal constructor does no processing on its string argument,
   54        * even if it is a null reference.  The public constructors will
   55        * never call this constructor with a null argument.
   56        */
   57       private AssertionError(String detailMessage) {
   58           super(detailMessage);
   59       }
   60   
   61       /**
   62        * Constructs an AssertionError with its detail message derived
   63        * from the specified object, which is converted to a string as
   64        * defined in <i>The Java Language Specification, Second
   65        * Edition</i>, Section 15.18.1.1.
   66        *<p>
   67        * If the specified object is an instance of <tt>Throwable</tt>, it
   68        * becomes the <i>cause</i> of the newly constructed assertion error.
   69        *
   70        * @param detailMessage value to be used in constructing detail message
   71        * @see   Throwable#getCause()
   72        */
   73       public AssertionError(Object detailMessage) {
   74           this("" +  detailMessage);
   75           if (detailMessage instanceof Throwable)
   76               initCause((Throwable) detailMessage);
   77       }
   78   
   79       /**
   80        * Constructs an AssertionError with its detail message derived
   81        * from the specified <code>boolean</code>, which is converted to
   82        * a string as defined in <i>The Java Language Specification,
   83        * Second Edition</i>, Section 15.18.1.1.
   84        *
   85        * @param detailMessage value to be used in constructing detail message
   86        */
   87       public AssertionError(boolean detailMessage) {
   88           this("" +  detailMessage);
   89       }
   90   
   91       /**
   92        * Constructs an AssertionError with its detail message derived
   93        * from the specified <code>char</code>, which is converted to a
   94        * string as defined in <i>The Java Language Specification, Second
   95        * Edition</i>, Section 15.18.1.1.
   96        *
   97        * @param detailMessage value to be used in constructing detail message
   98        */
   99       public AssertionError(char detailMessage) {
  100           this("" +  detailMessage);
  101       }
  102   
  103       /**
  104        * Constructs an AssertionError with its detail message derived
  105        * from the specified <code>int</code>, which is converted to a
  106        * string as defined in <i>The Java Language Specification, Second
  107        * Edition</i>, Section 15.18.1.1.
  108        *
  109        * @param detailMessage value to be used in constructing detail message
  110        */
  111       public AssertionError(int detailMessage) {
  112           this("" +  detailMessage);
  113       }
  114   
  115       /**
  116        * Constructs an AssertionError with its detail message derived
  117        * from the specified <code>long</code>, which is converted to a
  118        * string as defined in <i>The Java Language Specification, Second
  119        * Edition</i>, Section 15.18.1.1.
  120        *
  121        * @param detailMessage value to be used in constructing detail message
  122        */
  123       public AssertionError(long detailMessage) {
  124           this("" +  detailMessage);
  125       }
  126   
  127       /**
  128        * Constructs an AssertionError with its detail message derived
  129        * from the specified <code>float</code>, which is converted to a
  130        * string as defined in <i>The Java Language Specification, Second
  131        * Edition</i>, Section 15.18.1.1.
  132        *
  133        * @param detailMessage value to be used in constructing detail message
  134        */
  135       public AssertionError(float detailMessage) {
  136           this("" +  detailMessage);
  137       }
  138   
  139       /**
  140        * Constructs an AssertionError with its detail message derived
  141        * from the specified <code>double</code>, which is converted to a
  142        * string as defined in <i>The Java Language Specification, Second
  143        * Edition</i>, Section 15.18.1.1.
  144        *
  145        * @param detailMessage value to be used in constructing detail message
  146        */
  147       public AssertionError(double detailMessage) {
  148           this("" +  detailMessage);
  149       }
  150   }

Save This Page
Home » openjdk-7 » java » lang » [javadoc | source]