Exception thrown in catch and finally clause
Based on reading your answer and seeing how you likely came up with it, I believe you think an "exception-in-progress" has "precedence". Keep in mind:
When an new exception is thrown in a catch block or finally block, the current exception is aborted (and forgotten) and the new exception is thrown. The new exception starts unwinding up the stack just like any other exception, aborting out of the current block (the catch or finally block) and subject to any applicable catch or finally blocks along the way.
Note that applicable catch or finally blocks includes:
When a new exception is thrown in a catch block, the new exception is still subject to that catch's finally block, if any.
Now retrace the execution remembering that, whenever you hit throw
, you should abort tracing the current exception and start tracing the new exception.
当在catch和finally块中产生新异常, 当前的异常失效并被丢弃,新异常会被后续的catch和finally块处理。
注意: 一个新异常在catch块产生时,会被这个catch匹配的finally处理。
public class A { public static void main(String[] args) {
try{
exceptionFunction(); }catch(Exception e){ // print catches which Exception 111, 222, or 333.
System.out.println(e.getMessage());
}
} public static void exceptionFunction(){
try{
throw new IllegalArgumentException("111");
}catch(Exception e){
throw new IllegalArgumentException("222");
}finally{
throw new IllegalArgumentException("333");
}
}
}
above code will print:
333
Exception thrown in catch and finally clause的更多相关文章
- Exception thrown by the agent : java.rmi.server.ExportException: Port already in use
今天有个应用一直起不来,感觉配置都对啊,奇了怪了.看日志发现如下: STATUS | wrapper | 2017/01/04 08:09:31 | Launching a JVM...INFO | ...
- Selenium Grid 运行报错 Exception thrown in Navigator.Start first time ->Error forwarding the new session Empty pool of VM for setup Capabilities
Selenium Grid 运行报错 : Exception thrown in Navigator.Start first time ->Error forwarding the new se ...
- openstack-HTTP exception thrown: Maximum number of ports exceeded错误解决方案
最近几天什么都没动无法创建云主机了,经过一番查询 1.查日志 /data/jumpserver/logs 得到错误 HTTP exception thrown: Maximum number of p ...
- Exception thrown on Scheduler.Worker thread. Add `onError` handling
<html> <head></head> <body> java.lang.IllegalStateException: Exception throw ...
- eclipse的jdk版本和spring冲突问题WARN XmlWebApplicationContext:1060 - Exception thrown from LifecycleProcessor on context close
项目环境: jdk1.8 tomcat7 问题:eclipse启动tomcat后控制台报如下错误: WARN XmlWebApplicationContext:1060 - Exception thr ...
- tomcat启动报错“Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: iZ25fsk1ifk: iZ25fsk1ifk”
在启动了Tomcat的时候出现下面的错误,导致启动不了,卡在读日志的状态 Error: Exception thrown by the agent : java.net.MalformedURLExc ...
- springcloud 集成kafka问题记录,发消息报错:ERROR o.s.kafka.support.LoggingProducerListener - Exception thrown when sending a message with key='null' and payload='{-1,
在springcloud集成kafka,发送消息时报错: 2018-08-15 16:01:34.159 [http-nio-8081-exec-1] INFO org.apache.kafka.c ...
- 【Java】Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 1099
详细信息如下: Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: ...
- MyCat启动失败 Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: rebirth.a: rebirth.a: unknown error
在使用Nactive连接MyCat的时候发现怎么连接都不ok,明明已经启动了(实际上启动失败了)! 粗心的我,后来看了下日志,果然,启动失败了 Error: Exception thrown by t ...
随机推荐
- JNDI连接数据库的详细步骤 以及简要的c3po数据库连接的配置
第一步在tomcat的context.xml文件中配置数据源:context.xml的路径形式是:D:\Program Files (x86)\apache-tomcat-6.0.44\conf\co ...
- vue项目--favicon设置以及动态修改favicon
最近写公司项目时,动态更新favicon 动态更新之前需要有一个默认的favicon. 目前vue-cli搭建的vue项目里面已经有了一个static文件夹,存放静态文件. favicon图片放到该文 ...
- php实现二维码
封装函数 function verifyImage($len=3){ //session_start(); $scr="abcdefghijklmnoqprstuvwxyzABCDEFJHI ...
- Action中动态方法的调用 Action中通配符的使用 Result的配置
Action中动态方法的调用 动态方法调用(Dynamic Method Invocation,DMI) 标识符:! 一.通过以下选中的文件来查看是否禁止调用动态方法
- [Oracle] 关系型数据库排序算法和数据结构以及关联查询
关系型数据库排序算法和数据结构以及关联查询 1. Merge sort 理解merge sort算法将有助于更好地理解数据库join操作 - merge join 算法逻辑 将2个有序的大小为N/2的 ...
- git的使用03
之前我们写的都是将代码存在本地,我们还可以将代码github官网上,放在github的服务器上去托管
- mysql 故障整理
mysql> system mysqldump -uroot -p -B mingongge >/root/mingongge_bak.sql Enter password: mysqld ...
- hdu 5105(数学题)
Math Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- Codeforces Beta Round #4 (Div. 2 Only) A. Watermelon【暴力/数学/只有偶数才能分解为两个偶数】
time limit per test 1 second memory limit per test 64 megabytes input standard input output standard ...
- Python的并发并行[2] -> 队列[1] -> 使用队列进行任务控制
使用队列进行任务控制 1 FIFO与LIFO队列 FIFO(First In First Out)与LIFO(Last In First Out)分别是两种队列形式,在FIFO中,满足先入先出的队列方 ...