当前位置:网站首页>finally block can not complete normally
finally block can not complete normally
2022-06-21 08:33:00 【WCanTouch】
如果在try catch的时候finally中有return的时候就会报 finally block can not complete normally警告
这是由于以下的问题导致的:
程序出现了同意异常,可是却被JVM私吞,显然这是不好的做法。不建议在finally块中使用return语句的原因例如以下:
1、finally块中的return语句会覆盖前面的return语句(try块、catch块中的return语句)。会导致非常难推断方法的返回结果,easy得出错误的结论。
2、假设finally块中包括了return语句,即使前面的try或catch块抛出了异常,则调用该方法的语句也不会获得catch块又一次抛出的异常。而是会得到finally块的返回值。而且不会捕获异常。
所以尽量不要在finally中return
边栏推荐
- Given a two-dimensional list of m*n, find out whether a number exists
- Unity 5 自带的Mono也可以支持C# 6
- 日记(C语言总结)
- C # implement callback
- What should I do if a white page appears during MySQL installation
- Ads Filter Design Wizard tool 2
- 函数声明和函数表达式的区别
- Eureka's timedsupersortask class (periodic task with automatic interval adjustment)
- Summary of problems and errors encountered in tidb4.0.0 (tiup deployment)
- Topic34——31. 下一个排列
猜你喜欢

Gql+nodejs+mysql database

leetcode:19. 删除链表的倒数第 N 个结点

Windows10 LAN shared folder process

5分钟搞懂MySQL - 行转列

Using the method of combining shapes in illustrator

For hand drawn graphics, covering multiple topics, CVPR 2022 sketchdl workshop begins to solicit contributions!

日記(C語言總結)

Unity write multithreading considerations
![[yuanuniverse 3D competition]](/img/5e/386d2299ba62a78bd73982997d4df9.png)
[yuanuniverse 3D competition]

Classic topics of leetcode array (I)
随机推荐
C # implement callback
目前股票开户安全吗?可以直接网上开户吗?
2022-2028 global hydrogen engine industry research and trend analysis report
Higher order functions in kotlin (first-class citizens)
怎么搭建深度学习框架?
[MySQL performance optimization] - optimize query
2022-2028 global after sales spark plug industry research and trend analysis report
Post process basic notes (important items)
【C】【时间操作】C语言中关于时间的操作
写文章的markdown规则
Client construction and Optimization Practice
[DB written interview 366] stored procedures are codes stored in the database and have many advantages. Among the following statements, which are not the advantages of stored procedures are ()
GQL+Nodejs+MySQL数据库
Unmanned, automation technology affects the world
AQS source code exploration_ 01 handwriting a simplified reentrantlock reentrant lock
Kotlin---- detailed explanation of data types
[early knowledge of activities] list of recent activities of livevideostack
Requirements for setting up points sign in tasks and common problems in the process of building points mall
4.4 Eval function replaces function
在64位机器使用CMake编译32位程序