I thought it is compiling error due to final block will become unreachable code, but seems like not that case...
How does the compiler know there is/are unreachable code(s) or not?
About Question enthuware.ocajp.i.v7.2.1094 :
Moderator: admin
-
- Posts: 17
- Joined: Wed Jan 07, 2015 12:06 am
- Contact:
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1094 :
It is not possible to explain the whole concept of unreachable code in a post but the main thing is that the compiler cannot execute any code. It makes inferences only based on the existing code and decides whether some part of code is unreachable or not. Here, compiler cannot know what system.exit() does. You, as a programmer know that the JVM will exit but the compiler has no idea. For the compiler, it is just a method call. So it cannot make out that the finally block will never be executed. Here are a few links that you can go through:
http://stackoverflow.com/questions/9276 ... iler-error
https://coderanch.com/t/406677/java/unreachable-code
HTH,
Paul
http://stackoverflow.com/questions/9276 ... iler-error
https://coderanch.com/t/406677/java/unreachable-code
HTH,
Paul
Who is online
Users browsing this forum: No registered users and 8 guests