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 207264 - IllegalArgumentException: len=-2 < 0
Summary: IllegalArgumentException: len=-2 < 0
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 7.2
Hardware: All All
: P1 normal (vote)
Assignee: Jan Lahoda
: 206280 (view as bug list)
Depends on: 218053
  Show dependency tree
Reported: 2012-01-13 10:42 UTC by FrantaM
Modified: 2012-09-19 03:00 UTC (History)
11 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 183623

stacktrace (3.66 KB, text/plain)
2012-01-13 10:42 UTC, FrantaM
stacktrace (9.81 KB, text/plain)
2012-03-28 00:32 UTC, MackSix
stacktrace (2.10 KB, text/plain)
2012-07-27 23:30 UTC, jyeary
stacktrace (2.10 KB, text/plain)
2012-07-27 23:33 UTC, jyeary
stacktrace (9.89 KB, text/plain)
2012-08-02 12:30 UTC, misterm
stacktrace (2.10 KB, text/plain)
2012-08-03 11:48 UTC, jyeary
Project to use for reproduction. (23.44 KB, application/zip)
2012-09-12 11:14 UTC, MackSix
logfile (62.53 KB, text/plain)
2012-09-12 11:15 UTC, MackSix

Note You need to log in before you can comment on or make changes to this bug.
Description FrantaM 2012-01-13 10:42:03 UTC
Build: NetBeans IDE Dev (Build 201201080601)
VM: Java HotSpot(TM) 64-Bit Server VM, 22.0-b10, Java(TM) SE Runtime Environment, 1.7.0_02-b13
OS: Linux

User Comments:
GUEST: I was refactoring(renaming variables)

GUEST: refactoring Class

java.lang.IllegalArgumentException: len=-2 < 0
   at org.netbeans.editor.BaseDocument.handleRemove(
   at org.netbeans.editor.BaseDocument$FilterBypassImpl.remove(
   at javax.swing.text.DocumentFilter.remove(
   at org.openide.text.CloneableEditorSupport$DocFilter.remove(
   at org.netbeans.editor.BaseDocument.remove(
   at org.netbeans.modules.spring.beans.completion.SpringXMLConfigCompletionItem$
Comment 1 FrantaM 2012-01-13 10:42:06 UTC
Created attachment 114864 [details]
Comment 2 Milutin Kristofic 2012-01-16 11:03:02 UTC
There are three types of stacktraces, all related to factoring.
Comment 3 Miloslav Metelka 2012-02-22 15:27:29 UTC
Invalid length of document removal.
Comment 4 Martin Fousek 2012-03-23 12:57:22 UTC
Spring's case should be fixed by web-main #b0f849f3dd78.
Comment 5 Quality Engineering 2012-03-24 10:58:33 UTC
Integrated into 'main-golden', will be available in build *201203240400* on (upload may still be in progress)
User: Martin Fousek <>
Log: #207264 - IllegalArgumentException: len=-2 < 0
Comment 6 Quality Engineering 2012-03-25 09:43:11 UTC
Integrated into 'main-golden', will be available in build *201203250401* on (upload may still be in progress)
User: Martin Fousek <>
Log: #207264 - IllegalArgumentException: len=-2 < 0
Comment 7 MackSix 2012-03-28 00:32:21 UTC
Created attachment 117368 [details]

Trying to multi-replace a variable name with a new name in a Java class file.
Comment 8 Martin Fousek 2012-03-28 04:16:46 UTC
Most reports are java.source related, reassigning further for evaluation of their cases.
Comment 9 MackSix 2012-03-28 05:16:00 UTC
Here is how to reproduce it:

1.) Open a Java file in NetBeans.
2.) Put cursor on a variable name.
3.) Press Ctrl+R then Ctrl+F then Ctrl+R again.
4.) Rename dialog appears. 
5.) Rename variable and push the Refactor button.

This Exception happens.
Comment 10 jyeary 2012-07-27 23:30:33 UTC
Created attachment 122480 [details]

Attempted to refactor a value using CTRL+R to rename it.
Comment 11 jyeary 2012-07-27 23:33:34 UTC
Created attachment 122481 [details]
Comment 12 misterm 2012-08-02 12:30:45 UTC
Created attachment 122676 [details]
Comment 13 Exceptions Reporter 2012-08-02 12:30:53 UTC
This bug already has 50 duplicates 
Comment 14 misterm 2012-08-02 12:43:50 UTC
I was using Refactoring -> Change Method Parameters and changed both arguments order and the name of one of them when the exception was thrown.
Comment 15 jyeary 2012-08-03 11:48:45 UTC
Created attachment 122711 [details]

Failed to refactor the name of a variable. I was attempting to rename a variable using the CTRL + R reafactoring method.
Comment 16 Jan Lahoda 2012-09-10 09:02:06 UTC
I have separated the change method parameters test case:

For the (Java) rename refactoring testcase, sorry, but there is not enough information to fix that. I have added some debugging logs:
so when we have some messages.log with this data, it might be possible to find out what is wrong. But even better would be precise steps to reproduce. Thanks for your help.
Comment 17 Quality Engineering 2012-09-11 02:19:44 UTC
Integrated into 'main-golden', will be available in build *201209110001* on (upload may still be in progress)
User: Jan Lahoda <>
Log: #207264: adding debugging logs - keep creation stack traces for a few committed ModificationResults, and print them if commit fails.
Comment 18 Jan Lahoda 2012-09-11 13:02:08 UTC
*** Bug 206280 has been marked as a duplicate of this bug. ***
Comment 19 MackSix 2012-09-12 11:14:20 UTC
Created attachment 124231 [details]
Project to use for reproduction.

Here is how to reproduce it:

1.) Open attached project in NetBeans.
2.) Open up file in newpackage1.
3.) On line 12, put cursor in front of variable name "p".
4.) Press Ctrl+R and inline red editing box surrounds variable name.
5.) Then press Ctrl+F and the Find toolbar appears with "p" in find field.
6.) Then press Ctrl+R again and the Rename Field dialog pops up with "p" in field. 
7.) Rename variable to p1 and push the Refactor button.
Comment 20 MackSix 2012-09-12 11:15:53 UTC
Created attachment 124232 [details]

See attached logfile.
Comment 21 Jan Lahoda 2012-09-18 13:22:50 UTC
Thanks for the testcase. It is an interaction between instant rename and full refactoring. Fix attempt:
Comment 22 Quality Engineering 2012-09-19 03:00:09 UTC
Integrated into 'main-golden', will be available in build *201209190001* on (upload may still be in progress)
User: Jan Lahoda <>
Log: #207264: must cancel instant rename when running full refactoring.