emul/mini/src/main/java/java/lang/ClassNotFoundException.java
branchemul
changeset 554 05224402145d
parent 66 8a74b5d8d1d4
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/emul/mini/src/main/java/java/lang/ClassNotFoundException.java	Wed Jan 23 20:39:23 2013 +0100
     1.3 @@ -0,0 +1,125 @@
     1.4 +/*
     1.5 + * Copyright (c) 1995, 2004, 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 when an application tries to load in a class through its
    1.33 + * string name using:
    1.34 + * <ul>
    1.35 + * <li>The <code>forName</code> method in class <code>Class</code>.
    1.36 + * <li>The <code>findSystemClass</code> method in class
    1.37 + *     <code>ClassLoader</code> .
    1.38 + * <li>The <code>loadClass</code> method in class <code>ClassLoader</code>.
    1.39 + * </ul>
    1.40 + * <p>
    1.41 + * but no definition for the class with the specified name could be found.
    1.42 + *
    1.43 + * <p>As of release 1.4, this exception has been retrofitted to conform to
    1.44 + * the general purpose exception-chaining mechanism.  The "optional exception
    1.45 + * that was raised while loading the class" that may be provided at
    1.46 + * construction time and accessed via the {@link #getException()} method is
    1.47 + * now known as the <i>cause</i>, and may be accessed via the {@link
    1.48 + * Throwable#getCause()} method, as well as the aforementioned "legacy method."
    1.49 + *
    1.50 + * @author  unascribed
    1.51 + * @see     java.lang.Class#forName(java.lang.String)
    1.52 + * @see     java.lang.ClassLoader#findSystemClass(java.lang.String)
    1.53 + * @see     java.lang.ClassLoader#loadClass(java.lang.String, boolean)
    1.54 + * @since   JDK1.0
    1.55 + */
    1.56 +public class ClassNotFoundException extends ReflectiveOperationException {
    1.57 +    /**
    1.58 +     * use serialVersionUID from JDK 1.1.X for interoperability
    1.59 +     */
    1.60 +     private static final long serialVersionUID = 9176873029745254542L;
    1.61 +
    1.62 +    /**
    1.63 +     * This field holds the exception ex if the
    1.64 +     * ClassNotFoundException(String s, Throwable ex) constructor was
    1.65 +     * used to instantiate the object
    1.66 +     * @serial
    1.67 +     * @since 1.2
    1.68 +     */
    1.69 +    private Throwable ex;
    1.70 +
    1.71 +    /**
    1.72 +     * Constructs a <code>ClassNotFoundException</code> with no detail message.
    1.73 +     */
    1.74 +    public ClassNotFoundException() {
    1.75 +        super((Throwable)null);  // Disallow initCause
    1.76 +    }
    1.77 +
    1.78 +    /**
    1.79 +     * Constructs a <code>ClassNotFoundException</code> with the
    1.80 +     * specified detail message.
    1.81 +     *
    1.82 +     * @param   s   the detail message.
    1.83 +     */
    1.84 +    public ClassNotFoundException(String s) {
    1.85 +        super(s, null);  //  Disallow initCause
    1.86 +    }
    1.87 +
    1.88 +    /**
    1.89 +     * Constructs a <code>ClassNotFoundException</code> with the
    1.90 +     * specified detail message and optional exception that was
    1.91 +     * raised while loading the class.
    1.92 +     *
    1.93 +     * @param s the detail message
    1.94 +     * @param ex the exception that was raised while loading the class
    1.95 +     * @since 1.2
    1.96 +     */
    1.97 +    public ClassNotFoundException(String s, Throwable ex) {
    1.98 +        super(s, null);  //  Disallow initCause
    1.99 +        this.ex = ex;
   1.100 +    }
   1.101 +
   1.102 +    /**
   1.103 +     * Returns the exception that was raised if an error occurred while
   1.104 +     * attempting to load the class. Otherwise, returns <tt>null</tt>.
   1.105 +     *
   1.106 +     * <p>This method predates the general-purpose exception chaining facility.
   1.107 +     * The {@link Throwable#getCause()} method is now the preferred means of
   1.108 +     * obtaining this information.
   1.109 +     *
   1.110 +     * @return the <code>Exception</code> that was raised while loading a class
   1.111 +     * @since 1.2
   1.112 +     */
   1.113 +    public Throwable getException() {
   1.114 +        return ex;
   1.115 +    }
   1.116 +
   1.117 +    /**
   1.118 +     * Returns the cause of this exception (the exception that was raised
   1.119 +     * if an error occurred while attempting to load the class; otherwise
   1.120 +     * <tt>null</tt>).
   1.121 +     *
   1.122 +     * @return  the cause of this exception.
   1.123 +     * @since   1.4
   1.124 +     */
   1.125 +    public Throwable getCause() {
   1.126 +        return ex;
   1.127 +    }
   1.128 +}