Java ExceptionInInitializerError类
ExceptionInInitializerError类重点
抛出ExceptionInInitializerError错误表示静态初始值设定项中发生意外异常。即计算静态初始值设定项或静态变量初始值设定项期间发生异常。
ExceptionInInitializerError类源码
package java.lang;/*** Signals that an unexpected exception has occurred in a static initializer.* An <code>ExceptionInInitializerError</code> is thrown to indicate that an* exception occurred during evaluation of a static initializer or the* initializer for a static variable.* 表示静态初始值设定项中发生意外异常。* 抛出ExceptionInInitializerError以指示在计算静态初始值设定项* 或静态变量初始值设定项期间发生异常。** <p>As of release 1.4, this exception has been retrofitted to conform to* the general purpose exception-chaining mechanism. The "saved throwable* object" that may be provided at construction time and accessed via* the {@link #getException()} method is now known as the <i>cause</i>,* and may be accessed via the {@link Throwable#getCause()} method, as well* as the aforementioned "legacy method."* 从1.4版开始,此异常已进行了改装,以符合通用异常链接机制。* 可以在构造时提供并通过getException()方法访问的“保存的可丢弃对象”现在称为原因,* 可以通过 Throwable#getCause()方法以及前面提到的“遗留方法”访问** @author Frank Yellin* @since 1.1*/
public class ExceptionInInitializerError extends LinkageError {/*** Use serialVersionUID from JDK 1.1.X for interoperability*/private static final long serialVersionUID = 1521711792217232256L;/*** This field holds the exception if the* ExceptionInInitializerError(Throwable thrown) constructor was* used to instantiate the object** @serial**/private Throwable exception;/*** Constructs an <code>ExceptionInInitializerError</code> with* <code>null</code> as its detail message string and with no saved* throwable object.* A detail message is a String that describes this particular exception.*/public ExceptionInInitializerError() {initCause(null); // Disallow subsequent initCause}/*** Constructs a new <code>ExceptionInInitializerError</code> class by* saving a reference to the <code>Throwable</code> object thrown for* later retrieval by the {@link #getException()} method. The detail* message string is set to <code>null</code>.** @param thrown The exception thrown*/public ExceptionInInitializerError(Throwable thrown) {initCause(null); // Disallow subsequent initCausethis.exception = thrown;}/*** Constructs an ExceptionInInitializerError with the specified detail* message string. A detail message is a String that describes this* particular exception. The detail message string is saved for later* retrieval by the {@link Throwable#getMessage()} method. There is no* saved throwable object.*** @param s the detail message*/public ExceptionInInitializerError(String s) {super(s);initCause(null); // Disallow subsequent initCause}/*** Returns the exception that occurred during a static initialization that* caused this error to be created.** <p>This method predates the general-purpose exception chaining facility.* The {@link Throwable#getCause()} method is now the preferred means of* obtaining this information.** @return the saved throwable object of this* <code>ExceptionInInitializerError</code>, or <code>null</code>* if this <code>ExceptionInInitializerError</code> has no saved* throwable object.*/public Throwable getException() {return exception;}/*** Returns the cause of this error (the exception that occurred* during a static initialization that caused this error to be created).** @return the cause of this error or <code>null</code> if the* cause is nonexistent or unknown.* @since 1.4*/public Throwable getCause() {return exception;}
}
Java ExceptionInInitializerError类相关推荐
- java字符存储_用java的类集框架做一个字符存储器(15)
11.这是java的关于java的类集框架做一个字符存储器的源代码可以直接进行编译运行,希望大家能够从中获益良多. package niming; //导入ArrayList这个类 import ja ...
- 干货:排名前 16 的 Java 工具类!
2019独角兽企业重金招聘Python工程师标准>>> 干货:排名前 16 的 Java 工具类! 在Java中,工具类定义了一组公共方法,这篇文章将介绍Java中使用最频繁及最 ...
- 排名前 16 的 Java 工具类
转载来自微信公众号:Java 技术栈.如有侵权,请联系作者删除!! 在 Java 中,工具类定义了一组公共方法,这篇文章将介绍 Java 中使用最频繁及最通用的 Java 工具类.以下工具类.方法按使 ...
- Java枚举类使用方式
Java枚举类使用方式 单枚举定义 : /*** * @title: 单枚举定义* @author: wll* @since: 2021-1-27 14:47:54*/ public enum Jud ...
- java流类图结构_java I/O 流总结
一.java 流操作有关的类和接口: 类 说明 Fil ...
- Java Process类的浅学习
Java Process类的浅学习 文章分类:Java编程 今天用了下java.lang.Process类,只是初步的学习,并没有深入实践,因为感觉它的用途并不是很大,偶尔才可能用上,如果要经常使用它 ...
- java File类 常用相关函数
java File类 相关函数 1.构建函数 2.判断相关函数 4.创建相关函数 5.删除相关函数 6.获取相关函数 1.构建函数 /*** File 构造方法* file 常用构造方法* 1: Fi ...
- Java File类总结和FileUtils类
Java File类总结和FileUtils类 文件存在和类型判断 创建出File类的对象并不代表该路径下有此文件或目录. 用public boolean exists()可以判断文件是否存在. Fi ...
- java反射类的字段
java反射类的字段: package com.ma.reflection;import java.lang.reflect.Field;import org.junit.Test;import co ...
最新文章
- GAN 的发展对于研究通用人工智能有什么意义?
- 【VIOLA】宁可食无肉,不可居无竹
- 重写、重载方法的调用
- docker部署sprinboot项目
- Linux中的两种守护进程stand alone和xinetd
- 关于浙大考研878历年试卷的说明
- python字符串编码判断
- linux的文件解压命令,linux解压命令(linux解压文件命令)
- coreseek添加新词库
- Java的scjp_Java认证scjp考试过关攻略[转]
- 【MySQL】数据库命令练习题及答案
- Random Features for Large-Scale Kernel Machines笔记
- 王之泰201771010131《面向对象程序设计(java)》第一周学习总结
- android开源日志库的使用
- 反病毒垃圾邮件,U-Mail邮件系统从容应对
- 汉语拼音的36个韵母该怎么学?
- 《多媒体在初中数学中的运用研究》课题研究活动记录
- DHPST分销系统-EP分销-云主机分销系统
- VisualVm的理解
- 基于java的学生选课系统_基于Java的学生选课系统.doc