This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
[ BUILD # : 200511211900 ] [ JDK VERSION : 1.4.2_xx ] I am able to accidentally, or intentionally set a breakpoint on a comment within Java code. This is confusing, becuase at first glance I see a breakpoint and expect the program to break. Because it's on a comment line (or other), the program runs and runs. I'd expect a small warning (perhaps in the message area) indicating "Breakpoint cannot be set on the selected line".
I agree that the current behavior is not nice. But it's too late to change it for 5.0 release, since it's not trivial at all to detect where the breakpoints can be added and where not. Therefore I'm changing this to ehancement. There are already similar enhancements submitted as issue #15994, issue #31233 and issue #51728. We should resolve them for the next release...
*** Issue 43549 has been marked as a duplicate of this issue. ***
*** Issue 53488 has been marked as a duplicate of this issue. ***
*** Issue 77425 has been marked as a duplicate of this issue. ***
The problem is, that in general we can not know where it's possible to stop and where not. It depends on where the compiler decides to put locations. So until we have .class files, we can estimate only some well-known places where are no locations placed - like empty lines and comments (see issue #15994). Sun compiler also does not handle multi-line expressions.
We've implemented issue #51728, which helps to recognize places where it is possible to submit breakpoints and where not. Besides trivial cases like empty lines and comments (Java only, in JSP debugger steps through empty lines!) it's not easy to follow the rules according which compiler decides to pot locations. Also the rules are different for different compilers. This needs some well-though solution, so we'll postpone this for the next release.
*** Issue 112961 has been marked as a duplicate of this issue. ***
*** Issue 148963 has been marked as a duplicate of this issue. ***
*** Issue 151589 has been marked as a duplicate of this issue. ***
Fixed, the following rules are applied to handle breakpoints toggled on non-breakable lines: 1) Debugger does not run: - It is not allowed to toggle line breakpoint at empty lines, comments, local variable declarations without initializers, imports, empty statements. Whenever Toggle Line Breakpoint action is invoked (by Ctrl+F8, or by clicking at gutter), "Breakpoint cannot be set at this location" is reported in the status line and the IDE beeps. - When a line breakpoint is toggled at an empty line which is inside an expression, its position is automatically changed to the first line of the expression. This change is reported in the status line. - It is still possible to add a line breakpoint at any line using New Breakpoint dialog (Ctrl+Shift+F8). Moreover, breakpoint's validy is not checked after editing source code, neither after changing breakpoint's line number property. 2) Debugger runs: - If a line breakpoint cannot be submitted to virtual machine, the debugger tries to adjust its line number. When the breakpoint is inside an executable statement, its line number is changed to the statement's first line. If the breakpoint is in a block of statements, it is moved to the first line of the nearest statement above the breakpoint.
verified in NB 6.9 201005060200
For the reference - fixed by http://hg.netbeans.org/main/rev/297d0856d86