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 204788 - [71cat] StringIndexOutOfBoundsException: String index out of range: -20
Summary: [71cat] StringIndexOutOfBoundsException: String index out of range: -20
Status: RESOLVED WONTFIX
Alias: None
Product: editor
Classification: Unclassified
Component: Painting & Printing (show other bugs)
Version: 7.1
Hardware: All All
: P3 normal (vote)
Assignee: Miloslav Metelka
URL:
Keywords:
: 208116 209542 220843 249227 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-11-07 16:07 UTC by aldobrucale
Modified: 2016-07-07 07:29 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 182661


Attachments
stacktrace (7.82 KB, text/plain)
2011-11-07 16:07 UTC, aldobrucale
Details

Note You need to log in before you can comment on or make changes to this bug.
Description aldobrucale 2011-11-07 16:07:50 UTC
Build: NetBeans IDE Dev (Build 201111060600)
VM: Java HotSpot(TM) Client VM, 21.1-b02, Java(TM) SE Runtime Environment, 1.7.0_01-b08
OS: Linux

User Comments:
aldobrucale: Change Method Parameters -> click on "Default Value" column




Stacktrace: 
java.lang.StringIndexOutOfBoundsException: String index out of range: -20
   at java.lang.String.substring(String.java:1958)
   at java.lang.String.substring(String.java:1925)
   at org.netbeans.modules.refactoring.java.ui.ChangeParametersPanel$ParamEditor.getCellEditorValue(ChangeParametersPanel.java:1177)
   at javax.swing.JTable.editingStopped(JTable.java:4725)
   at javax.swing.AbstractCellEditor.fireEditingStopped(AbstractCellEditor.java:141)
   at javax.swing.DefaultCellEditor$EditorDelegate.stopCellEditing(DefaultCellEditor.java:368)
Comment 1 aldobrucale 2011-11-07 16:07:53 UTC
Created attachment 112935 [details]
stacktrace
Comment 2 Jan Becicka 2011-11-08 14:23:05 UTC
Cannot reproduce
Comment 3 Ralph Ruijs 2011-11-09 09:47:27 UTC
The problem is caused by removing characters before the document-view-start-position. Reassigning.
Comment 4 David Strupl 2011-11-11 15:39:39 UTC
Ralph, can you please explain a bit more why you assigned this to editor? All I see is the code in ChangeParametersPanel.java causing an exception ... startOffset being -20 causing the substring to fail and startOffset being filled from startOffset = ((String)model.getValueAt(row, col - 1)).length() + 1;. I know that I don't know what is inside the model and how it relates to the editor ... please explain.
Comment 5 Ralph Ruijs 2011-11-14 08:16:36 UTC
(In reply to comment #4)
> Ralph, can you please explain a bit more why you assigned this to editor? All I
> see is the code in ChangeParametersPanel.java causing an exception ...
> startOffset being -20 causing the substring to fail and startOffset being
> filled from startOffset = ((String)model.getValueAt(row, col - 1)).length() +
> 1;. I know that I don't know what is inside the model and how it relates to the
> editor ... please explain.

David, the startOffset being -20 is caused by the document-view-start-position incorrectly allowing to type before this position. Just checking if startOffset holds a 'valid' value will not work, as the document will remain in illegal state and throw exceptions.
Comment 6 Ralph Ruijs 2012-02-07 10:13:08 UTC
*** Bug 208116 has been marked as a duplicate of this bug. ***
Comment 7 Ralph Ruijs 2012-03-14 11:58:51 UTC
*** Bug 209542 has been marked as a duplicate of this bug. ***
Comment 8 Miloslav Metelka 2012-06-01 14:26:47 UTC
Seems to work fine in current 7.2 builds.
Comment 9 Jesse Glick 2012-06-01 17:56:38 UTC
Do you mean WORKSFORME? There is no specific fix changeset listed here.
Comment 10 Miloslav Metelka 2012-06-04 13:06:45 UTC
I have tried

> aldobrucale: Change Method Parameters -> click on "Default Value" column

and it worked fine in a recent dev build. Ralph could you please check whether this is really working now or not? Thanks.
Comment 11 Ralph Ruijs 2012-06-04 13:30:23 UTC
Mila, steps to reproduce.

1. Invoke change method parameters on a method
2. Add a new parameter
3. Remove all characters in the name column
4. Press backspace to remove a character before the document-view-start-position
5. Change focus out of the field



Product Version: NetBeans IDE Dev (Build 20120604-f99607e592c6)
Java: 1.6.0_31; Java HotSpot(TM) 64-Bit Server VM 20.6-b01-415
System: Mac OS X version 10.7.4 running on x86_64; MacRoman; en_US (nb)
Comment 12 Ralph Ruijs 2012-10-29 13:06:15 UTC
*** Bug 220843 has been marked as a duplicate of this bug. ***
Comment 13 Ralph Ruijs 2012-10-29 13:08:59 UTC
(In reply to comment #12)
> *** Bug 220843 has been marked as a duplicate of this bug. ***

The same problem as in cmp.

Open Introduce Parameter Refactoring
Select All on the parameter name textfield (CTRL+A)
Press backspace


When using document-view-start-position it should not be possible to change the text outside of the view.
Comment 14 markiewb 2014-12-09 13:49:40 UTC
*** Bug 249227 has been marked as a duplicate of this bug. ***
Comment 15 Martin Balin 2016-07-07 07:29:54 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss