Java 日看一类(31)之IO包中的InvalidClassException异常类和IOError异常类
2018-03-22 09:50
260 查看
InvalidClassException类无引入包
继承了ObjectStreamException
该类的类头注释如下:
/**
* Thrown when the Serialization runtime detects one of the following
* problems with a Class.
* <UL>
* <LI> The serial version of the class does not match that of the class
* descriptor read from the stream
* <LI> The class contains unknown datatypes
* <LI> The class does not have an accessible no-arg constructor
* </UL>
*
* @author unascribed
* @since JDK1.1
*/大意如下:
当下列问题在序列化出现时该异常被抛出:
序列化版本和从流中读取出类描述符的版本不匹配
类包含了不知名的数据类型
该类不含有可以无参数访问的构造函数
该类含有如下的成员变量:
序列化ID:private static final long serialVersionUID = -4333316296251054416L;无效的类型名public String classname;
该类含有如下的成员方法:
构造函数(上传错误原因public InvalidClassException(String reason) {
super(reason);
}构造函数(上传错误原因和错误类名public InvalidClassException(String cname, String reason) {
super(reason);
classname = cname;
}生成消息和类名(如果类名存在
public String getMessage() {
if (classname == null)
return super.getMessage();
else
return classname + "; " + super.getMessage();
}
该类和InvalidObjectException有一定的相似之处,也有一些不同(类和实例的错误不同),遇到时候请仔细分析
IOError无引入包
继承自Error类
该类的类头注释如下:/**
* Thrown when a serious I/O error has occurred.
*
* @author Xueming Shen
* @since 1.6
*/大意如下:
当发生严重的IO错误时该类被抛出
该类含有如下的成员变量:
序列化ID:private static final long serialVersionUID = 67100927991680413L;
该类含有如下的成员方法:
构造函数构造带有指定 cause 的新 IOError 实例。IOError 是使用详细消息 (cause==null ? null :cause.toString())(它通常包含 cause 的类和详细消息)创建的):public IOError(Throwable cause) {
super(cause);
}
该类被抛出的时候一般意味着出了比较大的问题,注意抛出时候的注释
继承了ObjectStreamException
该类的类头注释如下:
/**
* Thrown when the Serialization runtime detects one of the following
* problems with a Class.
* <UL>
* <LI> The serial version of the class does not match that of the class
* descriptor read from the stream
* <LI> The class contains unknown datatypes
* <LI> The class does not have an accessible no-arg constructor
* </UL>
*
* @author unascribed
* @since JDK1.1
*/大意如下:
当下列问题在序列化出现时该异常被抛出:
序列化版本和从流中读取出类描述符的版本不匹配
类包含了不知名的数据类型
该类不含有可以无参数访问的构造函数
该类含有如下的成员变量:
序列化ID:private static final long serialVersionUID = -4333316296251054416L;无效的类型名public String classname;
该类含有如下的成员方法:
构造函数(上传错误原因public InvalidClassException(String reason) {
super(reason);
}构造函数(上传错误原因和错误类名public InvalidClassException(String cname, String reason) {
super(reason);
classname = cname;
}生成消息和类名(如果类名存在
public String getMessage() {
if (classname == null)
return super.getMessage();
else
return classname + "; " + super.getMessage();
}
该类和InvalidObjectException有一定的相似之处,也有一些不同(类和实例的错误不同),遇到时候请仔细分析
IOError无引入包
继承自Error类
该类的类头注释如下:/**
* Thrown when a serious I/O error has occurred.
*
* @author Xueming Shen
* @since 1.6
*/大意如下:
当发生严重的IO错误时该类被抛出
该类含有如下的成员变量:
序列化ID:private static final long serialVersionUID = 67100927991680413L;
该类含有如下的成员方法:
构造函数构造带有指定 cause 的新 IOError 实例。IOError 是使用详细消息 (cause==null ? null :cause.toString())(它通常包含 cause 的类和详细消息)创建的):public IOError(Throwable cause) {
super(cause);
}
该类被抛出的时候一般意味着出了比较大的问题,注意抛出时候的注释
相关文章推荐
- Java 日看一类(30)之IO包中的InterruptedIOException、InvalidObjectException异常类
- Java 日看一类(35)之IO包中的ObjectInput接口
- Java 日看一类(19)之IO包中的FileOutputStream类
- Java 日看一类(24)之IO包中的FilterInputStream类
- Java 日看一类(25)之IO包中的FilterOutputStream类
- Java日看一类(2)之IO包中的BufferedInputStream类
- Java 日看一类(4)之IO包中的BufferedReader类
- Java 日看一类(1)之IO包中的Bits
- Java 日看一类(22)之IO包中的FileSystem类(抽象类
- Java 日看一类(34)之IO包中的NotActiveException和NotSerializableException
- Java 日看一类(18)之IO包中的FileNameFilter接口类和FileNotFoundException异常类
- Java 日看一类(7)之IO包中的ByteArrayOutputStream类
- Java 日看一类(9)之IO包中的CharConversionException类和Console类
- Java 日看一类(32)之IO包中的IOException类
- Java 日看一类(6)之IO包中的ByteArrayInputStream类
- Java 日看一类(11)之IO包中的DataInputStream类
- Java 日看一类(14)之IO包中的EOFException异常类和ExpiringCache内部类
- Java 日看一类(20)之IO包中的FilePermission类与FilePermissionCollection类
- Java 日看一类(13)之IO包中的DefaultFileSystem类和DeleteOnExitHook类
- Java 日看一类(28)之IO包中的Flushable接口和InputStream类