This content has been marked as final. Show 2 replies
Larry_E wrote:It is not clear to me why you need to insert if(true) to avoid compile error. This could be a compiler bug.
I put the if (true) to avoid the unreachable-code error I'd get otherwise.
Please provide more code to understand the compiler problem.
If I place a breakpoint on that statement (on the if line), it never fires. If I place it on the return statement, it does. If I put a method call before the if, and put a breakpoint there, it fires. Looking at the byte code, it is clear that the if (true) has been optimized out.Does the eclipse gives any error saying no code found at the line corresponding to "if(true)" statement or just ignored it.
So is this behavior to spec? Or is the Eclipse debugger at fault for not retargeting the breakpoint at the return statement? Or is the compiler at fault somehow?
Eclipse should print error msg. I do not think eclipse has been designed to set a break point at the next nearest statement.
jdb also does not do that. Optimizing the code this way is not a compiler fault. Only thing I will be looking at the need
of if(true) statement to avoid compile error. That could be a compiler issue.