01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package java.io;
19:
20: /**
21: * A problem was found with the class of one of the objects being serialized or
22: * deserialized. These can be
23: * <ul>
24: * <li>The SUIDs of the class loaded by the VM and the serialized class info do
25: * not match</li>
26: * <li>A serializable or externalizable object cannot be instantiated (when
27: * deserializing) because the empty constructor that needs to be run is not
28: * visible or fails.</li>
29: * </ul>
30: *
31: * @see ObjectInputStream #readObject()
32: * @see ObjectInputValidation#validateObject()
33: */
34: public class InvalidClassException extends ObjectStreamException {
35:
36: private static final long serialVersionUID = -4333316296251054416L;
37:
38: /**
39: * The fully qualified name of the class that caused the problem
40: */
41: public String classname;
42:
43: /**
44: * Constructs a new instance of this class with its walkback and message
45: * filled in.
46: *
47: * @param detailMessage
48: * The detail message for the exception.
49: */
50: public InvalidClassException(String detailMessage) {
51: super (detailMessage);
52: }
53:
54: /**
55: * Constructs a new instance of this class with its walkback, message and
56: * the fully qualified name of the class which caused the exception filled
57: * in.
58: *
59: * @param className
60: * The detail message for the exception.
61: * @param detailMessage
62: * The detail message for the exception.
63: */
64: public InvalidClassException(String className, String detailMessage) {
65: super (detailMessage);
66: this .classname = className;
67: }
68:
69: /**
70: * Answers the extra information message which was provided when the
71: * exception was created. If no message was provided at creation time, then
72: * answer null. If a message was provided and a class name which caused the
73: * exception, the values are concatenated and returned.
74: *
75: * @return The receiver's message, possibly concatenated with the name of
76: * the class that caused the problem.
77: */
78: @Override
79: public String getMessage() {
80: String msg = super .getMessage();
81: if (classname != null) {
82: msg = classname + "; " + msg; //$NON-NLS-1$
83: }
84: return msg;
85: }
86: }
|