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.

Bug 69462 - [50cat] Don't allow setting breakpoints on non-breakable code
Summary: [50cat] Don't allow setting breakpoints on non-breakable code
Status: VERIFIED FIXED
Alias: None
Product: debugger
Classification: Unclassified
Component: Code (show other bugs)
Version: 5.x
Hardware: PC Windows XP
: P2 blocker with 1 vote (vote)
Assignee: issues@debugger
URL:
Keywords:
: 43549 53488 77425 112961 148963 151589 (view as bug list)
Depends on: 89558
Blocks:
  Show dependency tree
 
Reported: 2005-11-28 15:56 UTC by clever
Modified: 2010-09-16 13:01 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description clever 2005-11-28 15:56:22 UTC
[ 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".
Comment 1 Martin Entlicher 2005-12-01 15:25:20 UTC
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...
Comment 2 Martin Entlicher 2005-12-13 17:20:52 UTC
*** Issue 43549 has been marked as a duplicate of this issue. ***
Comment 3 Martin Entlicher 2005-12-13 17:31:00 UTC
*** Issue 53488 has been marked as a duplicate of this issue. ***
Comment 4 Roman Ondruska 2006-06-06 11:04:27 UTC
*** Issue 77425 has been marked as a duplicate of this issue. ***
Comment 5 Martin Entlicher 2007-02-22 14:44:42 UTC
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.
Comment 6 Martin Entlicher 2007-03-13 18:23:14 UTC
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.
Comment 7 Martin Entlicher 2007-08-16 11:29:59 UTC
*** Issue 112961 has been marked as a duplicate of this issue. ***
Comment 8 Tomas Pavek 2009-05-15 17:35:37 UTC
*** Issue 148963 has been marked as a duplicate of this issue. ***
Comment 9 Tomas Pavek 2009-05-15 17:35:42 UTC
*** Issue 151589 has been marked as a duplicate of this issue. ***
Comment 10 Daniel Prusa 2010-03-04 08:31:24 UTC
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.
Comment 11 Marian Mirilovic 2010-05-10 09:39:56 UTC
verified in NB 6.9 201005060200
Comment 12 Martin Entlicher 2010-09-16 13:01:48 UTC
For the reference - fixed by http://hg.netbeans.org/main/rev/297d0856d86