01: /*
02: * @(#)InvalidClassException.java 1.24 06/10/10
03: *
04: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: *
26: */
27:
28: package java.io;
29:
30: /**
31: * Thrown when the Serialization runtime detects one of the following
32: * problems with a Class.
33: * <UL>
34: * <LI> The serial version of the class does not match that of the class
35: * descriptor read from the stream
36: * <LI> The class contains unknown datatypes
37: * <LI> The class does not have an accessible no-arg constructor
38: * </UL>
39: *
40: * @author unascribed
41: * @version 1.17, 02/02/00
42: * @since JDK1.1
43: */
44: public class InvalidClassException extends ObjectStreamException {
45: /**
46: * Name of the invalid class.
47: *
48: * @serial Name of the invalid class.
49: */
50: public String classname;
51:
52: /**
53: * Report a InvalidClassException for the reason specified.
54: *
55: * @param reason String describing the reason for the exception.
56: */
57: public InvalidClassException(String reason) {
58: super (reason);
59: }
60:
61: /**
62: * Constructs an InvalidClassException object.
63: *
64: * @param cname a String naming the invalid class.
65: * @param reason a String describing the reason for the exception.
66: */
67: public InvalidClassException(String cname, String reason) {
68: super (reason);
69: classname = cname;
70: }
71:
72: /**
73: * Produce the message and include the classname, if present.
74: */
75: public String getMessage() {
76: if (classname == null)
77: return super .getMessage();
78: else
79: return classname + "; " + super.getMessage();
80: }
81: }
|