try..catch
来源:互联网 发布:淘宝网成唯识论直解 编辑:程序博客网 时间:2024/06/17 21:18
如果try语句块中出现属于Exception或其子类的异常,则转到catch语句块处理。
如果try语句块中出现不属于Exception或其子类的异常,则转到finally语句块处理。
如果catch语句块中出现任何异常,则转到finally语句块处理
//Java源码public int inc(){int x;try{x=1;return x;}catch(Exception e){x=2;return x;}finally{x=3;}}//编译后的ByteCode字节码及异常表public int inc();Code:Stack=1,Locals=5,Args_size=10:iconst_1//try块中的x=11:istore_12:iload_1//保存x到returnValue中,此时x=13:istore 45:iconst_3//finaly块中的x=36:istore_17:iload 4//将returnValue中的值放到栈顶,准备给ireturn返回9:ireturn10:astore_2//给catch中定义的Exception e赋值,存储在Slot 2中11:iconst_2//catch块中的x=212:istore_113:iload_1//保存x到returnValue中,此时x=214:istore 416:iconst_3//finaly块中的x=317:istore_118:iload 4//将returnValue中的值放到栈顶,准备给ireturn返回20:ireturn21:astore_3//如果出现了不属于java.lang.Exception及其子类的异常才会走到这里22:iconst_3//finaly块中的x=323:istore_124:aload_3//将异常放置到栈顶,并抛出25:athrowException table:from to target type0 5 10 Class java/lang/Exception0 5 21 any10 16 21 any
阅读全文
0 0
- try catch
- try{} catch{}
- try catch
- try...catch
- try{} catch(...){}
- try catch
- try-catch
- try catch
- try-catch
- try catch
- try catch
- try catch
- try catch
- try catch
- try {...} catch (){....}
- try{} catch{}
- try catch
- Try catch
- Intellij IDEA配置tomcat(非maven项目)
- linux系统jconsole的使用和windows远程查看
- 苹果核
- Python爬虫之正则 & BeautifulSoup4解析HTML
- Guice依赖注入(@Inject)
- try..catch
- 从尾到头打印链表(含翻转链表两种方法)
- MYSQL数据库(四) 数据插入、空值和非空判断、自动排序、主键约束、唯一约束
- OpenGL基本操作与SOIL库和assimp库的使用
- exec()方法
- qt串口通信学习笔记
- 【错误】java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
- ASP.NET WebAPI 实战问题总结(一)
- 网络编程中Nagle算法和Delayed ACK的测试