Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 344984

Summary: BadLocationException from ToggleBreakpointAdapter when trying to toggle watchpoint
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: DebugAssignee: Michael Rennie <Michael_Rennie>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Michael_Rennie
Version: 3.7   
Target Milestone: 3.8 M6   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Markus Keller CLA 2011-05-06 11:04:47 EDT
I20110504-0800

- import org.eclipse.jdt.ui as source (from CVS or using the PDE importer)
- open type ModifyDialog
- double-click the left ruler on line 94 to set a watchpoint for field
	private final Map<String, String> fWorkingValues;

=> watchpoint is not created, exception in log:

org.eclipse.jface.text.BadLocationException
	at org.eclipse.jface.text.ListLineTracker.getLineInformation(ListLineTracker.java:180)
	at org.eclipse.jface.text.AbstractLineTracker.getLineInformation(AbstractLineTracker.java:137)
	at org.eclipse.jface.text.AbstractDocument.getLineInformation(AbstractDocument.java:929)
	at org.eclipse.core.internal.filebuffers.SynchronizableDocument.getLineInformation(SynchronizableDocument.java:337)
	at org.eclipse.jdt.internal.debug.ui.actions.ToggleBreakpointAdapter$2.run(ToggleBreakpointAdapter.java:261)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 1 Markus Keller CLA 2011-05-06 11:16:57 EDT
Simpler example:

package xy;

public class Try {
    private final String fWorkingValues; // Breakpoint here 
    
    Try() {
        fWorkingValues= null;
        System.out.println(fWorkingValues);
    }
}
Comment 2 Michael Rennie CLA 2012-02-29 16:51:08 EST
We end up falling back to setting a line breakpoint on the next valid line (since you can't set a watchpoint on a final field), the problem is that we do not have a validator when we invoke toggleBreakpoints, so we are guessing the wrong location.
Comment 3 Michael Rennie CLA 2012-03-02 18:23:26 EST
There was even a bit more to it - we were creating two jobs in place of one, passing a bogus value for a line number and allowing final field to be found as valid locations for watchpoints in our AST visitor.

Pushed fix to: http://git.eclipse.org/c/jdt/eclipse.jdt.debug.git/commit/?id=20b68383657cd467297bd15f92d8b6233809a6c0