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 180980 - javax.swing.text.BadLocationException: Invalid offset=1889 not within <0, 1888>
Summary: javax.swing.text.BadLocationException: Invalid offset=1889 not within <0, 1888>
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Painting & Printing (show other bugs)
Version: 6.x
Hardware: All All
: P2 normal (vote)
Assignee: Miloslav Metelka
URL:
Keywords:
: 184101 184390 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-02-19 11:54 UTC by mjreged
Modified: 2010-11-24 06:12 UTC (History)
19 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 165466


Attachments
stacktrace (2.20 KB, text/plain)
2010-02-19 11:54 UTC, mjreged
Details
stacktrace (5.79 KB, text/plain)
2010-04-13 14:19 UTC, Lukas Hasik
Details
stacktrace (3.53 KB, text/plain)
2010-04-13 14:34 UTC, Andrei Chistiakov
Details
stacktrace (4.58 KB, text/plain)
2010-04-13 20:10 UTC, Jesse Glick
Details
stacktrace (4.58 KB, text/plain)
2010-04-13 20:16 UTC, Jesse Glick
Details
stacktrace (2.20 KB, text/plain)
2010-04-19 23:07 UTC, misterm
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mjreged 2010-02-19 11:54:48 UTC
This bug was originally marked as duplicate of bug 172978, that is already resolved. This bug is still valid, so this seems to be another bug, but it might be related.

Build: NetBeans IDE Dev (Build 201002152000)
VM: Java HotSpot(TM) Client VM, 16.0-b13, Java(TM) SE Runtime Environment, 1.6.0_18-b07
OS: Windows XP

User Comments:
ashl1: Interrupt debuggibg

mjreged: while editing java class

GUEST: I was editing a source code.

GUEST: writing c++, pasting "cout << endl;" from buffer

paul_floyd: Pasting an enum element into a switch case in a C file

pif17: don't know why, coding with C module

lsvidal: I was using code completition on some classes I created. I can send the source code if you need.




Stacktrace: 
javax.swing.text.BadLocationException: Invalid offset=1889 not within <0, 1888>
   at org.netbeans.editor.Utilities.checkOffsetValid(Utilities.java:1389)
   at org.netbeans.editor.Utilities.checkOffsetValid(Utilities.java:1384)
   at org.netbeans.editor.Utilities.getRowStart(Utilities.java:156)
   at org.netbeans.editor.Utilities.getRowStart(Utilities.java:139)
   at org.netbeans.editor.CodeFoldingSideBar.traverseForward(CodeFoldingSideBar.java:332)
   at org.netbeans.editor.CodeFoldingSideBar.getPaintInfo(CodeFoldingSideBar.java:299)
Comment 1 mjreged 2010-02-19 11:54:54 UTC
Created attachment 94348 [details]
stacktrace
Comment 2 Lukas Hasik 2010-04-13 14:19:39 UTC
Created attachment 97205 [details]
stacktrace

http://smetiste.czech.sun.com/builds/netbeans/6.9/beta/2010-04-12_22-01-23-javafx/ 

-install, start IDE
-create new JavaFX Application and exception appears
Comment 3 Andrei Chistiakov 2010-04-13 14:34:39 UTC
Created attachment 97207 [details]
stacktrace

scrolled JavaFX source in editor while scanning projects was in progress
Comment 4 Andrei Chistiakov 2010-04-13 14:43:31 UTC
Product Version: NetBeans IDE 6.9 Beta (Build 201004122201)
Java: 1.6.0_18; Java HotSpot(TM) Client VM 16.0-b13
System: SunOS version 5.11 running on x86; UTF-8; en_US (nb)

The exception is endless, blocking source editor functionality . Raising to P1.
Comment 5 David Strupl 2010-04-13 20:09:22 UTC
Is it affected by the view hierarchy? Can you get rid of it by disabling the line wrap by
-J-Dorg.netbeans.editor.linewrap=false
?
But it looks like the "artificial end of line at the last line" problem from the first glance at the exception text.
Comment 6 Jesse Glick 2010-04-13 20:10:41 UTC
Created attachment 97246 [details]
stacktrace
Comment 7 Jesse Glick 2010-04-13 20:16:40 UTC
Created attachment 97247 [details]
stacktrace
Comment 8 Jesse Glick 2010-04-13 20:17:54 UTC
> Can you get rid of it by disabling the line wrap by
> -J-Dorg.netbeans.editor.linewrap=false ?

No.

Thrown after typing any character or just displaying an editor buffer; makes IDE unusable. Need a hotfix ASAP (parented to a cset in main-silver so it can be merged into team repos).
Comment 9 Vitezslav Stejskal 2010-04-13 20:51:16 UTC
(In reply to comment #8)
> > Can you get rid of it by disabling the line wrap by
> > -J-Dorg.netbeans.editor.linewrap=false ?
> 
> No.

Correct. This DOES happen with -J-Dorg.netbeans.editor.linewrap=false, but does NOT happen with -J-Dorg.netbeans.editor.linewrap=true. Therefore, this mainly affects 6.9beta where -J-D...linewrap=false is the default option.
Comment 10 Jesse Glick 2010-04-13 21:01:40 UTC
(In reply to comment #9)
> this mainly affects 6.9beta where -J-D...linewrap=false is the default option

Or anyone else using dev builds who wants to disable line wrap mode to avoid other serious bugs.
Comment 11 Jesse Glick 2010-04-13 21:04:05 UTC
(In reply to comment #8)
> Need a hotfix ASAP (parented to a cset in main-silver

Probably best parented to release69_base if not earlier, for easy merging.

(I tried to use 'hg bisect' to find the cause, but I could not reproduce it when I actually wanted to, as is typical.)
Comment 12 Vitezslav Stejskal 2010-04-13 21:50:03 UTC
(In reply to comment #11)
> (I tried to use 'hg bisect' to find the cause, but I could not reproduce it
> when I actually wanted to, as is typical.)

IMO it's caused by http://hg.netbeans.org/main-silver/rev/4d62d39b41e7, which was ported to 6.9beta branch as http://hg.netbeans.org/release69_beta/rev/d910d8c94b8e.

Btw. we should add o.n.e.Utilities to exception reporter's list of innocent classes, because these failures have nothing to do with the original problem that this bug was filed for.
Comment 13 Jesse Glick 2010-04-13 22:26:45 UTC
(In reply to comment #12)
>> I tried to use 'hg bisect' to find the cause, but I could not reproduce it
> 
> IMO it's caused by #4d62d39b41e7

No, I knew about this and so passed both system properties to make sure line wrap was disabled in each version.
Comment 14 err 2010-04-14 01:04:28 UTC
> DOES happen with -J-Dorg.netbeans.editor.linewrap=false,
> does NOT happen with -J-Dorg.netbeans.editor.linewrap=true.

Matches what I'm seeing. SCROLLING causes the problem when near the END OF FILE.

Later stacktraces have a different signature, Highlight code:
javax.swing.text.BadLocationException: Invalid offset=336 not within <0, 335>
   ...
   at org.netbeans.modules.editor.url.HighlightURLs.getHighlights(HighlightURLs.java:96)
   at org.netbeans.modules.editor.lib2.highlighting.ProxyHighlightsContainer.getHighlights(ProxyHighlightsContainer.java:121)
   at org.netbeans.modules.editor.lib.drawing.HighlightingDrawLayer.processOffset(HighlightingDrawLayer.java:627)
   ...


Product Version: NetBeans IDE Dev (Build 201004131450)
Java: 1.6.0_18; Java HotSpot(TM) Client VM 16.0-b13
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
Userdir: C:\Documents and Settings\erra\.netbeans\dev
Comment 15 Vitezslav Stejskal 2010-04-14 08:02:59 UTC
http://hg.netbeans.org/jet-main/rev/14c2cbfc781f - parented to release69_beta_base.
Comment 16 Alexandr Scherbatiy 2010-04-14 08:22:16 UTC
*** Bug 184101 has been marked as a duplicate of this bug. ***
Comment 17 Vitezslav Stejskal 2010-04-14 09:54:17 UTC
Ported to release69_beta clone as:
http://hg.netbeans.org/release69_beta/rev/d6f74efda521
http://hg.netbeans.org/release69_beta/rev/c4c9d78f739b
Comment 18 Jesse Glick 2010-04-14 14:18:23 UTC
(In reply to comment #17)
> Ported to release69_beta clone as:
> http://hg.netbeans.org/release69_beta/rev/d6f74efda521

BTW the whole point of parenting 14c2cbfc781f to release69_beta_base is so you can pull the changeset directly without using transplant. But never mind.
Comment 19 Vitezslav Stejskal 2010-04-19 10:12:40 UTC
*** Bug 184390 has been marked as a duplicate of this bug. ***
Comment 20 misterm 2010-04-19 23:07:57 UTC
Created attachment 97676 [details]
stacktrace
Comment 21 Marian Petras 2010-10-22 16:50:29 UTC
Apparently, this bug is not fixed properly as it has happened in NB 7.0 M2. See http://statistics.netbeans.org/exceptions/detail.do?id=165466, duplicate 432275.

This happened in NB 7.0 M2, JDK 6u22 64-bit, while editing source code of a plain Java class. I think it happened just after manual invocation of code-completion.

Or maybe this bug is fixed in NB 6.9 but somehow the fix did not get to 7.0?
Comment 22 David Strupl 2010-10-22 17:39:07 UTC
Milo, can you please have a look? Thanks a lot.
Comment 23 Miloslav Metelka 2010-11-23 16:14:40 UTC
The doc.getLength() + 1 is now a valid offset for the particular methods in org.netbeans.editor.Utilities.

http://hg.netbeans.org/jet-main/rev/9502a92fe28f
Comment 24 Quality Engineering 2010-11-24 06:12:16 UTC
Integrated into 'main-golden', will be available in build *201011240001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/9502a92fe28f
User: Miloslav Metelka <mmetelka@netbeans.org>
Log: #180980 - javax.swing.text.BadLocationException: Invalid offset=1889 not within <0, 1888> - allow methods in o.n.editor.Utilities to use doc.getLength()+1 offset.