`
jiangchuhan
  • 浏览: 16146 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

finally块的问题(finally block does not complete normally)

 
阅读更多

当finall块中包含return语句时,Eclipse会给出警告“finally block does not complete normally”,原因分析如下:

1、不管try块、catch块中是否有return语句,finally块都会执行。
2、finally块中的return语句会覆盖前面的return语句(try块、catch块中的return语句),所以如果finally块中有return语句,Eclipse编译器会报警告“finally block does not complete normally”。

3、如果finally块中包含了return语句,即使前面的catch块重新抛出了异常,则调用该方法的语句也不会获得catch块重新抛出的异常,而是会得到finally块的返回值,并且不会捕获异常。

结论,应避免在finally块中包含return语句。如果你在前面的语句中包含了return语句或重新抛出了异常,又在finally块中包含了return语句,说明你概念混淆,没有理解finally块的意义。

分享到:
评论

相关推荐

    squashfs1.3r3.tar.gz

    This is the default action if dest does not exist, or if no filesystem is on it -keep-as-directory If one source directory is specified, create a root directory containing that directory, ...

    Nand Flash ECC

    NOR Flash normally does not need ECC (Error-Correcting Code). On the other hand, NAND requires ECC to ensure data integrity. NAND Flash includes extra storage on each page to store ECC code as well ...

    CommandFailedException.rar_out

    Thrown when an out of process executable does not return normally.

    fat-tailed and skewed asset return distributions

    evidence does not support the assumption that many important variables in finance follow a normal distribution. The application of the Central Limit Theorem to such instances is often inappropriate ...

    Universal-USB-Installer

    does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable ...

    2009 达内Unix学习笔记

    用法 df [-F FSType] [-abeghklntVvZ] [-o FSType 特定选项] [目录 | 块设备 | 资源] df -k 以kbytes显示文件大小的查看文件系统方式 六、显示文件内容 more 分屏显示文件的内容。 用法 more [-cdflrsuw] [-行...

    Python library

    on their semantics, but does not fully define the semantics. The library also contains built-in functions and exceptions — objects that can be used by all Python code without the need of an import ...

    Normally-open-switch.rar_The Open Road

    Normally open switch, two road relay device.the control, time can be adjusted

    Nonlinearequationssolver_非线性方程求解_fifteendvd_

    介绍非线性方程求解的函数,用法。附有m文件,供科研人员参考。

    WizFlow网页编辑

    be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of ...

    hibernate-shards.jar

    be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of ...

    issrc-5.3.3.zip_The Front_delphi inno setup

    Compil32 does not do the actual compilation itself it relegates it to ISCmplr.dll. If the ISCmplr project is changed, you normally don t need to recompile Compil32 since it s essentially a text ...

    lettuce-exit-normally

    问题 连接到集群后,JVM不会退出。 我该如何重现? 启动redis集群。 docker run -e "IP=0.0.0.0" -p 7000-7005:7000-7005 grokzen/redis-cluster:latest 然后运行: make test

    Large displacement FEM modelling of the cone penetration test (CPT) in normally

    Large displacement FEM modelling of the cone penetration test (CPT) in normally

    squashfs2.2-r2.tar.gz

    files which do not fit fully into a block, are NOT by default packed into fragments. To illustrate this, a 100K file has an initial 64K block and a 36K remainder. This 36K remainder is not packed into...

    微软内部资料-SQL性能优化2

    Assuming the page reference does not result in an access violation, a page fault can be either hard or soft. A hard page fault results in a read from disk, either a page file or memory-mapped file. A...

    语音朗读精灵(SmartRead)

    What does not 不连接互联网时,会发生自动退出的情况。 Do not connect to the Internet, will automatically withdraw from the case. What was not tested 把文字转换成swf文件。 Text to swf file. ...

    LuaUnicode icu-lua

    string.sub(s, -3) will return the last 3 bytes of the string which is not necessarily the same as the last three characters of the string, and may or may not be a complete code. You could use the ...

    High-Performance Normally-Off Al2O3/GaN MOSFET Using a Wet Etching-Based Gate Recess Technique

    High-Performance Normally-Off Al2O3/GaN MOSFET Using a Wet Etching-Based Gate Recess Technique

    Programming LEGO EV3 My Blocks.pdf

    An overview of FIRST ® LEGO® League (FLL®) for those who might not be familiar with it, followed by a description of the Robot Game, the purpose and focus of the book, and finally how the book is ...

Global site tag (gtag.js) - Google Analytics