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 177660 - StringIndexOutOfBoundsException: String index out of range: -4
Summary: StringIndexOutOfBoundsException: String index out of range: -4
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 6.x
Hardware: All All
: P2 normal (vote)
Assignee: Jan Lahoda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-26 04:34 UTC by Erno Mononen
Modified: 2010-01-25 08:13 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 148981


Attachments
stacktrace (1.26 KB, text/plain)
2009-11-26 04:34 UTC, Erno Mononen
Details
stacktrace (1.26 KB, text/plain)
2009-11-26 08:15 UTC, Jan Pokorsky
Details
stacktrace (1.26 KB, text/plain)
2009-11-27 07:57 UTC, Karol Harezlak
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Erno Mononen 2009-11-26 04:34:38 UTC
Build: NetBeans IDE Dev (Build 200911251400)
VM: Java HotSpot(TM) 64-Bit Server VM, 16.0-b08, Java(TM) SE Runtime Environment, 1.7.0-ea-b71
OS: Linux, 2.6.27-15-generic, amd64

User Comments:
GUEST: remove cast

GUEST: casting

GUEST: casting

GUEST: Tried to move a class from one package to another (via drag-and-drop).
Sometimes refactoring works, sometimes it doesn't, although it's consistant per specific file. That is, I can move class X from package A to B, but cannot move class Y from package C to D.

t_yano: I used a refacturring action 'inner to outer' against inner enum class.

mhuebner: clicked on "surround block with try/catch"

emononen: Applied a hint suggesting casting

GUEST: removing cast



Stacktrace: 
java.lang.StringIndexOutOfBoundsException: String index out of range: -4
        at java.lang.String.substring(String.java:1949)
        at org.netbeans.modules.java.source.save.CasualDiff.diff(CasualDiff.java:176)
        at org.netbeans.api.java.source.WorkingCopy.processCurrentCompilationUnit(WorkingCopy.java:444)
        at org.netbeans.api.java.source.WorkingCopy.getChanges(WorkingCopy.java:505)
        at org.netbeans.api.java.source.JavaSource$1.run(JavaSource.java:662)
        at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:129)
Comment 1 Erno Mononen 2009-11-26 04:34:42 UTC
Created attachment 91721 [details]
stacktrace
Comment 2 Jan Pokorsky 2009-11-26 08:15:48 UTC
Created attachment 91733 [details]
stacktrace
Comment 3 Karol Harezlak 2009-11-27 07:57:48 UTC
Created attachment 91783 [details]
stacktrace
Comment 4 Exceptions Reporter 2009-12-03 03:54:18 UTC
This bug already has 20 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=148981
Comment 5 Jan Lahoda 2009-12-18 08:59:08 UTC
I am not completely sure what is the root cause, but I think that the CompilationUnitTree.getLineMap is likely not correctly updated after partial reparse. I have introduced a workaround that should hopefully fix this particular exception:
http://hg.netbeans.org/jet-main/rev/74966fd2ac95

I have created a new bug #178862 to keep track about the CUT.getLineMap().

The workaround might be a good 6.8 patch1 candidate.
Comment 6 Quality Engineering 2009-12-19 23:40:30 UTC
Integrated into 'main-golden', will be available in build *200912200200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/74966fd2ac95
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #177660: trying to prevent a StringIndexOutOfBoundsException.
Comment 7 pgebauer 2010-01-06 04:18:45 UTC
The whiteboard changed back to 68patch-candidate. The whiteboard 68patch1-candidate can be added by QA or Sustaining to issues those has been verified in the trunk already.
Comment 8 Peter Pis 2010-01-14 06:38:25 UTC
I was not able to reproduce. Verified in trunk.
Comment 9 pgebauer 2010-01-14 13:12:43 UTC
The fix has been ported into the release68_fixes repository.
http://hg.netbeans.org/release68_fixes/rev/73705aa8e9e0
Comment 10 Peter Pis 2010-01-25 08:13:32 UTC
V.