Community
Participate
Working Groups
If the brace charactere which marks the end of a method body is the first charactere of its line, the implicit 'return' which is added at the end of the method bytecode has as location the line above. An exemple: 1. compile the following compilation unit in Eclipse (just copy/paste, don't change the indentation): public class Test { public static void main(String[] args) { boolean v= false; if (v) // <-- breakpoint here System.out.println("hi there"); } } 2. add the breakpoint and launch the program. 3. when the breakpoint is hit, do a step over. the 'System.out...' line is highlighted, it looks like the test of the 'if' is true, even if it's impossible. 4. do resume, nothing is print in the consol. So, as expected, the 'System.out.println("hi there")' is not executed. 5. Edit the compilation unit, add a space charactere just before the brace which close the method body. 6. Re-compile and re-launch. 7. After hit the breakpoint, do a step over. This time, the correct line is higtlighted, the line which contains the closing brace.
Olivier - I thought we had addressed this scenario using the closing '}' ...
I would say the closing parenthesis position is incorrect in this case. I need to double-check.
In this example, the bodyEnd of the main method is the position of the \n in the System.out line. It should be the position of the '}' following this line. So the free return problem was addressed, but it is assuming a correct position for the bodyEnd of the method.
Changing this.bodyEnd = endPosition; with this.bodyEnd = endStatementPosition; fixes the problem. I need to double-check that there is no side-effect with this. endPosition is the character right before the '}'. endStatementPosition is the right position. So the bug wasn't with the handling of the free-return, but rather with the correctness of the this.bodyEnd position.
The body end is supposed to be the last character before the closing '}', so I would think it is currently ok (also it has ramifications in syntax recovery, so be careful). I would say that you should rather use the declarationSourcEnd instead.
Using the declarationSourceEnd fixed the problem. I will release the code today.
Fixed and released in HEAD.
Please also backport to R2_0_1 stream
backported to 2.0.1.
Verified.
Verified
Verfied in 2.1 M1