KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > io > InvalidClassException


1 /*
2  * @(#)InvalidClassException.java 1.20 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.io;
9
10 /**
11  * Thrown when the Serialization runtime detects one of the following
12  * problems with a Class.
13  * <UL>
14  * <LI> The serial version of the class does not match that of the class
15  * descriptor read from the stream
16  * <LI> The class contains unknown datatypes
17  * <LI> The class does not have an accessible no-arg constructor
18  * </UL>
19  *
20  * @author unascribed
21  * @version 1.20, 12/19/03
22  * @since JDK1.1
23  */

24 public class InvalidClassException extends ObjectStreamException JavaDoc {
25     /**
26      * Name of the invalid class.
27      *
28      * @serial Name of the invalid class.
29      */

30     public String JavaDoc classname;
31
32     /**
33      * Report a InvalidClassException for the reason specified.
34      *
35      * @param reason String describing the reason for the exception.
36      */

37     public InvalidClassException(String JavaDoc reason) {
38     super(reason);
39     }
40
41     /**
42      * Constructs an InvalidClassException object.
43      *
44      * @param cname a String naming the invalid class.
45      * @param reason a String describing the reason for the exception.
46      */

47     public InvalidClassException(String JavaDoc cname, String JavaDoc reason) {
48     super(reason);
49     classname = cname;
50     }
51
52     /**
53      * Produce the message and include the classname, if present.
54      */

55     public String JavaDoc getMessage() {
56     if (classname == null)
57         return super.getMessage();
58     else
59         return classname + "; " + super.getMessage();
60     }
61 }
62
Popular Tags