Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/io/InvalidClassException.java
38829 views
/*1* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.io;2627/**28* Thrown when the Serialization runtime detects one of the following29* problems with a Class.30* <UL>31* <LI> The serial version of the class does not match that of the class32* descriptor read from the stream33* <LI> The class contains unknown datatypes34* <LI> The class does not have an accessible no-arg constructor35* </UL>36*37* @author unascribed38* @since JDK1.139*/40public class InvalidClassException extends ObjectStreamException {4142private static final long serialVersionUID = -4333316296251054416L;4344/**45* Name of the invalid class.46*47* @serial Name of the invalid class.48*/49public String classname;5051/**52* Report an InvalidClassException for the reason specified.53*54* @param reason String describing the reason for the exception.55*/56public InvalidClassException(String reason) {57super(reason);58}5960/**61* Constructs an InvalidClassException object.62*63* @param cname a String naming the invalid class.64* @param reason a String describing the reason for the exception.65*/66public InvalidClassException(String cname, String reason) {67super(reason);68classname = cname;69}7071/**72* Produce the message and include the classname, if present.73*/74public String getMessage() {75if (classname == null)76return super.getMessage();77else78return classname + "; " + super.getMessage();79}80}818283