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 ...
随机推荐
- BZOJ5297 [Cqoi2018]社交网络 【矩阵树定理】
题目链接 BZOJ5297 题解 最近这玩意这么那么火 这题要用到有向图的矩阵树定理 主对角线上对应入度 剩余位置如果有边则为\(-1\),不然为\(0\) \(M_{i,i}\)即为以\(i\)为根 ...
- 基于WEB的机器人远程控制
1.前进后退左转右转控制: 2.视频传输,为了保证视频的流畅性,选择相机支持格式中图像最小,帧率最低的:并对视频进行处理,将15帧处理成5帧,从而降低传输数据量: 3.地图显示及导航控制: 地图在三维 ...
- js字符串使用占位符拼接
由于几个老项目中经常用到jquery拼接字符串,各种引号很disgusting 所以写了一个占位符拼接的的方法 String.prototype.signMix= function() { if(ar ...
- Angular(三)
一.使用Module(模块)组织依赖关系 模块提供了一种方法,可以用来组织应用中一块功能区域的依赖关系:同时还提供了一种机制,可以自动解析依赖关系(又叫做依赖注入).一般来说,我们把这些叫做依赖服务, ...
- tips 前端 点击事件
新手总是时不时会纠结一下 点击事件 我们都知道这些小东西不难 但是偶尔难道不会想想我们可能对这些即使小kiss的问题的认知其实不够清晰 一个认识不清晰的东西使用时 总会有油然而生的不安感 从而用的不放 ...
- 重建二叉树_C++
一.题目背景 给定一个二叉树的前序和中序遍历,求出它的后序遍历 二叉树的遍历可参考 http://blog.csdn.net/fansongy/article/details/6798278/ 二.算 ...
- malloc,calloc,realloc区别
malloc:memory allocation calloc:The 'c' indicates 'cleared' realloc:The realloc() function changes t ...
- 《Linux命令行与shell脚本编程大全 第3版》创建实用的脚本---11
以下为阅读<Linux命令行与shell脚本编程大全 第3版>的读书笔记,为了方便记录,特地与书的内容保持同步,特意做成一节一次随笔,特记录如下:
- Java中UML图
原文出处:http://blog.sina.com.cn/s/blog_7b3a17130100r95y.html 类(Class) 类(图A)是对象的蓝图,其中包含3个组成部分.第一个是Java中定 ...
- 华为上机测试题(地铁换乘-java)
PS:自己写的,自测试OK,供大家参考. /* 高级题样题:地铁换乘描述:已知2条地铁线路,其中A为环线,B为东西向线路,线路都是双向的.经过的站点名分别如下,两条线交叉的换乘点用T1.T2表示.编写 ...