/[classpath]/classpath/java/io/InvalidClassException.java
ViewVC logotype

Diff of /classpath/java/io/InvalidClassException.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by mark, Tue Jan 22 22:26:59 2002 UTC revision 1.8 by ericb, Sun Feb 24 04:25:16 2002 UTC
# Line 1  Line 1 
1  /* InvalidClassException.java -- An I/O operation was interrupted.  /* InvalidClassException.java -- deserializing a class failed
2     Copyright (C) 1998 Free Software Foundation, Inc.     Copyright (C) 1998, 2002 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 7  GNU Classpath is free software; you can Line 7  GNU Classpath is free software; you can
7  it under the terms of the GNU General Public License as published by  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2, or (at your option)  the Free Software Foundation; either version 2, or (at your option)
9  any later version.  any later version.
10    
11  GNU Classpath is distributed in the hope that it will be useful, but  GNU Classpath is distributed in the hope that it will be useful, but
12  WITHOUT ANY WARRANTY; without even the implied warranty of  WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Line 39  exception statement from your version. * Line 39  exception statement from your version. *
39  package java.io;  package java.io;
40    
41  /**  /**
42    * This exception is thrown when there is some sort of problem with a   * This exception is thrown when there is some sort of problem with a
43    * class during a serialization operation.  This could be that the   * class during a serialization operation.  This could be:<br><ul>
44    * versions don't match, that there are unknown datatypes in the class   * <li>the serial version of the class doesn't match</li>
45    * or that the class doesn't have a default no-arg constructor.   * <li>the class contains unknown datatypes</li>
46    * <p>   * <li>the class does not have an accessible no-arg constructor</li>
47    * The field <code>classname</code> will contain the name of the   * </ul>.
48    * class that caused the problem if known.  The getMessage() method   *
49    * for this exception will always include the name of that class   * <p>The field <code>classname</code> will contain the name of the
50    * if known.   * class that caused the problem if known.  The getMessage() method
51    *   * for this exception will always include the name of that class
52    * @version 0.0   * if known.
53    *   *
54    * @author Aaron M. Renn (arenn@urbanophile.com)   * @author Aaron M. Renn (arenn@urbanophile.com)
55    */   * @since 1.1
56     * @status updated to 1.4
57     */
58  public class InvalidClassException extends ObjectStreamException  public class InvalidClassException extends ObjectStreamException
59  {  {
60    /**    /**
61      * The name of the class which encountered the error.     * Compatible with JDK 1.1+.
62      */     */
63      private static final long serialVersionUID = -4333316296251054416L;
64    
65      /**
66       * The name of the class which encountered the error.
67       *
68       * @serial the classname causing the error
69       */
70    public String classname;    public String classname;
71    
72    /**    /**
73      * Create a new InvalidClassException with a descriptive error message String     * Create an exception with a descriptive error message, but a null
74      *     * classname.
75      * @param message The descriptive error message     *
76      */     * @param message the descriptive error message
77       */
78    public InvalidClassException(String message)    public InvalidClassException(String message)
79    {    {
80      super(message);      super(message);
81    }    }
82    
83    /**    /**
84      * Create a new InvalidClassException with a descriptive error message     * Create an exception with a descriptive error message, and the name of
85      * String, and the name of the class that caused the problem.     * the class that caused the problem.
86      *     *
87      * @param classname The number of bytes tranferred before the interruption     * @param classname the name of the faulty class
88      * @param message The descriptive error message     * @param message the descriptive error message
89      */     */
90    public InvalidClassException(String classname, String message)    public InvalidClassException(String classname, String message)
91    {    {
92      super(message);      super(message);
# Line 84  public class InvalidClassException exten Line 94  public class InvalidClassException exten
94    }    }
95    
96    /**    /**
97      * Returns the descriptive error message for this exception.  It will     * Returns the descriptive error message for this exception. It will
98      * include the class name that caused the problem if known.  This method     * include the class name that caused the problem if known, in the format:
99      * overrides Throwable.getMessage()     * <code>[classname][; ][super.getMessage()]</code>.
100      *     *
101      * @return A descriptive error message     * @return A descriptive error message, may be null
102      */     */
103    public String getMessage()    public String getMessage()
104    {    {
105      return super.getMessage() + (classname == null ? "" : ": " + classname);      String msg = super.getMessage();
106        if (msg == null)
107          return classname;
108        return (classname == null ? "" : classname + "; ") + msg;
109    }    }
110  }  }
111    

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26