try finally return Exception
来源:互联网 发布:德瓦管在淘宝上叫什么 编辑:程序博客网 时间:2024/06/04 04:07
1.当finally中没有return语句时, 生成的字节码包含了对异常的处理public static int tryReturnFinally() { int i = 0; try { i++; i = i / 0; return i; } finally { i++; } } public static int tryReturnFinally(); descriptor: ()I flags: ACC_PUBLIC, ACC_STATIC Code: stack=2, locals=3, args_size=0 0: iconst_0 1: istore_0 2: iinc 0, 1 5: iload_0 6: iconst_0 7: idiv 8: istore_0 9: iload_0 10: istore_2 11: iinc 0, 1 14: iload_2 15: ireturn 16: astore_1 17: iinc 0, 1 20: aload_1 21: athrow Exception table: from to target type 2 11 16 any LineNumberTable: line 11: 0 line 13: 2 line 14: 5 line 15: 9 line 17: 11 line 15: 14 line 16: 16 line 17: 17 line 18: 20 LocalVariableTable: Start Length Slot Name Signature 2 20 0 i I StackMapTable: number_of_entries = 1 frame_type = 255 /* full_frame */ offset_delta = 16 locals = [ int ] stack = [ class java/lang/Throwable ] 2.当finally中有return语句时, 生成的字节码不包含对异常的处理,仅进行finally return处理,忽略try中的return语句,忽略异常public static int tryReturnFinallyReturn() { int i = 0; try { i++; i = i / 0; return i; } finally { i++; return i; } } public static int tryReturnFinallyReturn(); descriptor: ()I flags: ACC_PUBLIC, ACC_STATIC Code: stack=2, locals=1, args_size=0 0: iconst_0 1: istore_0 2: iinc 0, 1 5: iload_0 6: iconst_0 7: idiv 8: istore_0 9: goto 13 12: pop 13: iinc 0, 1 16: iload_0 17: ireturn Exception table: from to target type 2 12 12 any LineNumberTable: line 24: 0 line 26: 2 line 27: 5 line 28: 9 line 29: 12 line 30: 13 line 31: 16 LocalVariableTable: Start Length Slot Name Signature 2 16 0 i I StackMapTable: number_of_entries = 2 frame_type = 255 /* full_frame */ offset_delta = 12 locals = [ int ] stack = [ class java/lang/Throwable ]
0 0
- try finally return Exception
- Try-Finally-Return
- java try return finally
- try finally return
- try catch finally return?
- try catch finally return
- try catch finally return
- try-finally-return
- try...catch...finally中的return
- try catch finally 和return
- try中的return与finally
- Python中的try, finally, return
- try{}中return和finally{}
- try、catch、finally巧遇return
- try、catch、finally巧遇return
- try...catch...finally中的return
- try-catche-finally和return
- try finally中的return问题
- 2.7.3 对键盘进行设置
- 草,真真逗b
- weka:SimpleKMeans实现Class to clusters evaluation验证
- 优先选择基本类型
- 黑马程序员——内存管理
- try finally return Exception
- Android:Material Design兼容库(Design Support Library)
- keepalived+haproxy实现nginx与mysql负载均衡
- VBScript基础
- Ibean
- 我是如何向老婆解释MapReduce的?
- hive常用属性设置
- Http协议学习笔记
- Java主函数参数不同形式的辨析