"finally block does not complete normally"警告解决
转载地址:http://www.cnblogs.com/interdrp/p/4095846.html
java里面不是可以保证finally一定会执行的么,为什么不可以在finally块做return?
细细看道来:
debug一下这个函数,就会惊讶的发现, 里面抛出的异常会被finally吃掉。 这也就是为什么会被警告的原因。
@SuppressWarnings( "finally" )
private boolean isReturnWithinFinally()
{
try {
if ( true )
throw new RuntimeException();
} finally {
return(true); /* This hides the exception */
}
}
那么,下面这样会不会ok呢?先把异常处理
public static void main( String[] args )
{
try{
throw new RuntimeException();
}catch ( Exception e ) {
/* */
}
finally {
return;
}
}
结论是:依旧不行。java里面的异常分为可不获和不可捕获两类,即便使用到catch块,也会导致非捕获的错误被finally吃掉。
因此,return一定要放到finally外面。
"finally block does not complete normally"警告解决的更多相关文章
- eclipse黄色警告(finally block does not complete normally) ,不建议在finally中使用return语句
在eclipse中编写例如以下的代码,eclipse会给出黄色告警:finally block does not complete normally. public class Test { publ ...
- finally块的问题(finally block does not complete normally) (转)
当finall块中包含return语句时,Eclipse会给出警告“finally block does not complete normally”,原因分析如下: 1.不管try块.catch块中 ...
- finally块的问题(finally block does not complete normally)
http://blog.csdn.net/chh_jiang/article/details/4557461 当finall块中包含return语句时,Eclipse会给出警告“finally blo ...
- Apple Mach-O Linker Warning 警告解决的方法
此警告解决的方法: 项目名字 -> targets -> Build Settings -> search path 把里面无用的东西 点 减号 删掉 即可了. $(function ...
- Redis 启动警告解决【转】
[root@centos224]# service redisd start :M Nov :: (it was originally set to ). _._ _.-``__ ''-._ _.-` ...
- coreldraw x5提示盗版警告解决方法
CorelDRAW是一款图形图像软件,大多数用户使用的都是coreldraw x5破解版,所以基本上都收到了coreldraw x5提示盗版警告,导致不能用,没关系,绿茶小编有解决方法. coreld ...
- Apple Mach-O Linker Warning 警告解决办法
此警告解决办法: 项目名字 -> targets -> Build Settings -> search path
- Redis 启动警告解决
Redis 启动警告解决[转] [root@centos224]# service redisd start 21985:M 24 Nov 04:07:20.376 * Increased maxim ...
- IDEA maven 项目报警告解决(自己的maven配置记录)
IDEA maven 项目报警告解决 应该是JDK版本太低 虽然你装的高但是默认使用maven 默认的 这里要配一下JDK版本 理解不深入只为 自己记录使用 1 配置 仓库为阿里云 配置本地储存j ...
随机推荐
- 每天一点点之laravel框架开发 - Laravel5.6去除URL中的index.php
在项目routes/web.php文件中添加了自定义的路由后,访问localhost/index.php/aaa,可以正常访问,但是去掉index.php后,提示404 Not Found 1. 按照 ...
- Adobe Photoshop CC2014 for MAC 详细破解步骤
1,安装Adobe Photoshop CC2014 for MAC,可以断网安装,如果不断网的话,需要申请一个Adobe ID,是免费申请. 2,下载破解工具,https://sdifen.ctfi ...
- windows driver 写数据到txt
HANDLE hFile; OBJECT_ATTRIBUTES oa; IO_STATUS_BLOCK iosb; LARGE_INTEGER li; UNICODE_STRING strPath = ...
- Beyond Compare 文件对比工具的使用
Beyond Compare 文件对比工具的使用 Beyond Compare 工具下载地址: http://www.onlinedown.net/soft/633850.htm 本文下载地址:E:\ ...
- Cannot access android.support.v4.app.*
解决办法: 添加到受影响的 module build.gradle 中(比如app的gradle文件根代码下) configurations.all { resolutionStrategy.each ...
- 《Thinking in Java》中讲到了final,发现自己有部分地方迷糊
1.1当给全局的静态字段加上final时,系统是不会给其赋默认值的,若不手动初始化,会编译时错误——Variable 'xxx' might not have been initialized. 1. ...
- 报错:Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
1.问题 写了一个简单的单层神经网络跑mnist手写数字集,结果每次fit都会出现dead kernel 很多dead kernel首先不要急着去网上搜dead kernel怎么解决,因为大家出现的原 ...
- POJ 1129:Channel Allocation 四色定理+暴力搜索
Channel Allocation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13357 Accepted: 68 ...
- you-get使用
1.pip install you-get 2.如果出错 查看错误bug you-get http://www.iqiyi.com/v_19rrnqxz7k.html#vfrm=2-4-0-1 ...
- 备份 分区表 mbr
备份方法: 1.备份分区表信息 sudo fdisk -l >hda.txt #分区表信息重定向输出到文件中 2.备份MBR linux@linux-desktop:~/ex$ sudo ...