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的更多相关文章

  1. 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 | ...

  2. 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 ...

  3. openstack-HTTP exception thrown: Maximum number of ports exceeded错误解决方案

    最近几天什么都没动无法创建云主机了,经过一番查询 1.查日志 /data/jumpserver/logs 得到错误 HTTP exception thrown: Maximum number of p ...

  4. Exception thrown on Scheduler.Worker thread. Add `onError` handling

    <html> <head></head> <body> java.lang.IllegalStateException: Exception throw ...

  5. eclipse的jdk版本和spring冲突问题WARN XmlWebApplicationContext:1060 - Exception thrown from LifecycleProcessor on context close

    项目环境: jdk1.8 tomcat7 问题:eclipse启动tomcat后控制台报如下错误: WARN XmlWebApplicationContext:1060 - Exception thr ...

  6. 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 ...

  7. 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 ...

  8. 【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: ...

  9. 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 ...

随机推荐

  1. 关于Yarn源码那些事-前传之ResourceManager篇(一)初始化

    在关于Yarn那些事的博客里,介绍的主要是针对任务提交的一个动态流程说明,而其中牵涉到的一些细节问题,必须通过Resourcemanager的启动和NodeManager的启动,来更好的说明. 而本系 ...

  2. BZOJ2716 [Violet 3]天使玩偶 【CDQ分治】

    题目 输入格式 输出格式 输入样例 //样例太长就不贴了.... 输出样例 //见原题 提示 题解 我们将曼哈顿距离式子中的绝对值去掉,每次只考虑x,y比当前点小的更新答案. 为了使所有点都对答案进行 ...

  3. JavaScript各变量类型的判断方法

    我们很容易被漂亮的代码吸引,也不知不觉的在自己的代码库中加入这些.却没有冷静的想过它们的优劣.这不,我就收集了一系列形如 "是否为……?" 的判断的boolean函数. isNul ...

  4. [原]C++拾遗

    int a=3,b=4; bool ok=(a==2,b==4); printf("%d\n",ok); //输出的结果是1,逗号既不是&& 也不是|| 应该是从前 ...

  5. cms .net webform去服务器控件标签化 pagebase新版本

    这是最近在干一个webform的cms的时候用起来的,原来虽然做过很多技术,什么remoting,wcf,webservice,可是弄来弄去,最后也没个收藏的地儿,全都放在笔记本儿上了,可是人又懒地可 ...

  6. java keytool证书工具使用小结(转)

    Keytool 是一个Java数据证书的管理工具 ,Keytool将密钥(key)和证书(certificates)存在一个称为keystore的文件中在keystore里,包含两种数据:密钥实体(K ...

  7. 解决svn 异常:svn: E155027: Tree conflict can only be resolved to working state; {0} not resolved

    以前很少使用svn进行代码管理,时间长了之后也忘得差不多了,但现在公司使用的是svn进行版本管理,使用过程中出现了问题,顺带记一下. 异常情况:切换svn地址之后,发现项目代码无法合并代码,也无法提交 ...

  8. mysql故障(程序正在运行却找不到PID文件)

    [root@slave ~]# /etc/init.d/mysql status ERROR! MySQL is running but PID file could not be found [ro ...

  9. hdu 5159(概率)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5159 题解:假设在 x 张牌中选b张牌,那么有 x^b 种选法,如果在 (x-1) 张牌中选 b 张 ...

  10. c++不允许指向常量的指针赋值给不指向常量的指针

    #include <iostream> using namespace std; class A { public: int i; int j; } int main() { const ...