]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2002-06-17 Nathanael Nerode <neroden@twcny.rr.com>
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 Jun 2002 19:15:22 +0000 (19:15 +0000)
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 Jun 2002 19:15:22 +0000 (19:15 +0000)
* java/lang/ClassNotFoundException.java: New Classpath version.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@54713 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/java/lang/ClassNotFoundException.java

index ea816d9df8d543b650b7937e249ee3e13769e320..508122709dfe6c0d7a461bc77731284f277587ce 100644 (file)
@@ -1,3 +1,7 @@
+2002-06-17  Nathanael Nerode  <neroden@twcny.rr.com>
+
+       * java/lang/ClassNotFoundException.java: New Classpath version.
+
 2002-06-17  Nathanael Nerode  <neroden@twcny.rr.com>
 
        * java/rmi/activation/ActivateFailedException.java: Remerge from
index 11b792b183b15f4cc2c8a68ea13c03edff449035..cb546602e56dc9bdeefc4f772f5e403d16f00e96 100644 (file)
@@ -1,6 +1,5 @@
-/* ClassNotFoundException.java -- exception thrown when attempting to load
-   a class when no definition for the class can be found.
-   Copyright (C) 1998 Free Software Foundation, Inc.
+/* ClassNotFoundException.java -- thrown when class definition cannot be found
+   Copyright (C) 1998, 2002 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -8,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2, or (at your option)
 any later version.
+
 GNU Classpath is distributed in the hope that it will be useful, but
 WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
@@ -39,137 +38,88 @@ exception statement from your version. */
 
 package java.lang;
 
-import java.io.ObjectOutputStream;
-import java.io.ObjectInputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-
 /**
- * Exceptions may be thrown by one part of a Java program and caught
- * by another in order to deal with exceptional conditions.  This 
- * exception can by thrown by specific methods of <code>ClassLoader</code>
- * and <code>Class</code> when attempting to load a class when no definition
- * for the specified class can be found.
+ * Thrown when a class is requested by reflection, but the class definition
+ * cannot be found. This exception is often chained from another Throwable.
  *
- * @since JDK 1.0
- * 
  * @author Brian Jones
+ * @author Eric Blake <ebb9@email.byu.edu>
+ * @see Class#forName(String)
+ * @see ClassLoader#findSystemClass(String)
+ * @see ClassLoader#loadClass(String, boolean)
+ * @status updated to 1.4
  */
 public class ClassNotFoundException extends Exception
 {
-  static final long serialVersionUID = 9176873029745254542L;
-
-  private Throwable ex = null;
-  
   /**
-   * Create an exception without a message.
+   * Compatible with JDK 1.0+.
    */
-  public ClassNotFoundException()
-    {
-      super();
-    }
+  private static final long serialVersionUID = 9176873029745254542L;
 
   /**
-   * Create an exception with a message.
-   */
-  public ClassNotFoundException(String s)
-    {
-      super(s);
-    }
-
-  /**
-   * Create an exception with a message and include the exception 
-   * which occurred while loading the class.
-   *
-   * @param ex the exception which occurred while loading the class
+   * The cause of this exception (duplicates the one stored in Throwable).
    *
-   * @since JDK 1.2
+   * @serial the exception cause
+   * @since 1.2
    */
-  public ClassNotFoundException(String s, Throwable ex)
-    {
-      super(s);
-      this.ex = ex;
-    }
+  private final Throwable ex;
 
   /**
-   * Returns the exception which occurred while loading the class, 
-   * otherwise returns null.
-   * 
-   * @since JDK 1.2
+   * Create an exception without a message. Note that this initializes the
+   * cause to null.
    */
-  public Throwable getException()
-    {
-      return ex;
-    }
+  public ClassNotFoundException()
+  {
+    this(null, null);
+  }
 
   /**
-   * Print a stack trace of the exception that occurred.
+   * Create an exception with a message. Note that this initializes the
+   * cause to null.
+   *
+   * @param s the message
    */
-  public void printStackTrace()
-    {
-      if (ex == null)
-        {
-          super.printStackTrace();
-        }
-      else
-        {
-          ex.printStackTrace();
-        }
-    }
+  public ClassNotFoundException(String s)
+  {
+    this(s, null);
+  }
 
   /**
-   * Print a stack trace of the exception that occurred to 
-   * the specified <code>PrintStream</code>.
+   * Create an exception with a message and chain it to the exception
+   * which occurred while loading the class.
+   *
+   * @param s the message
+   * @param ex the chained exception
+   * @since 1.2
    */
-  public void printStackTrace(PrintStream ps)
-    {
-      if (ex == null)
-        {
-          super.printStackTrace(ps);
-        }
-      else
-        {
-          ex.printStackTrace(ps);
-        }
-    }
+  public ClassNotFoundException(String s, Throwable ex)
+  {
+    super(s, ex);
+    this.ex = ex;
+  }
 
   /**
-   * Print a stack trace of the exception that occurred to 
-   * the specified <code>PrintWriter</code>.
+   * Returns the exception which occurred while loading the class,
+   * otherwise returns null. This is a legacy method; the preferred choice
+   * now is {@link Throwable#getCause()}.
+   *
+   * @return the cause of this exception
+   * @since 1.2
    */
-  public void printStackTrace(PrintWriter pw)
-    {
-      if (ex == null)
-        {
-          super.printStackTrace(pw);
-        }
-      else
-        {
-          ex.printStackTrace(pw);
-        }
-    }
+  public Throwable getException()
+  {
+    return ex;
+  }
 
   /**
-   * Serialize the object in a manner binary compatible with the JDK 1.2
+   * Returns the exception which occurred while loading the class,
+   * otherwise returns null.
+   *
+   * @return the cause of this exception
+   * @since 1.4
    */
-  private void writeObject(java.io.ObjectOutputStream s) 
-    throws IOException
-    {
-      ObjectOutputStream.PutField oFields;
-      oFields = s.putFields();
-      oFields.put("ex", this.ex);
-      s.writeFields(); 
-    }
-
-  /**
-   * Deserialize the object in a manner binary compatible with the JDK 1.2
-   */    
-  private void readObject(java.io.ObjectInputStream s)
-    throws IOException, ClassNotFoundException
-    {
-      ObjectInputStream.GetField oFields;
-      oFields = s.readFields();
-      ex = (Throwable)oFields.get("ex", (Throwable)null);
-    }
+  public Throwable getCause()
+  {
+    return ex;
+  }
 }