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.
Refactor-Rename fails to rename variables named 'enum'. Renaming 'enum' to 'iter' in this line of code: Enumeration enum = new Vector().elements(); Produces this: Enumeration iternew Vector().elements(); (Source code attached.)
Created attachment 52466 [details] Demo failure in renaming 'enum' variable name
Reproduced in 6.0 Beta 2. May be related to Issue 72263 (Cannot rename enum field).
In jdk 1.5 and later 'enum' is a keyword. Your source is broken and the refactoring should not proceed. It is a P4 defect. In order to refactor this case you have to use source level 1.4 or java platform 1.4 in your project properties. Note that compiler annotations warn you about this.
Please reevaluate priority. There's still tons of code written for older versions of Java that needs to be rebuilt (and possibly ported) to Java 5 or later. NetBeans should make this process easier, not break the code even more. The renaming support is clearly broken in this case. Try the demo provided and you'll see errors in the log file. There's also no way to undo, AFAICT. The renaming support needs to either balk at attempting to rename a variable in broken code, or do it correctly.
[NetBeans IDE Dev (Build 071102)] It is probably a misunderstanding. Of course we still support older code but you have to use proper configuration then. As I wrote there is an incompatibility between JDK 1.4 and 1.5 as the new keyword enum was introduced. So to refactor such a code either use java platform 1.4 or use source level 1.4 in case you use java platform 1.5 or higher for your project. The red underwave warns you about that. Move the mouse over the underwaved code to see detailed warning. What errors in log are you talking about? I see no attachment here and if I try to reproduce no error is logged too. Undo seems to be really broken in this case. I agree again the refactoring should balk but it is P4 issue.
I'm afraid the existing behavior may result in a bad experience for first-time NetBeans users trying to build old code. Another likely scenario is: Naive user types in some Java code using 'enum' as a variable name and then tries to fix it using the rename action. The reviewer's explanation of the source setting is interesting, but it's not something a new user will be aware of. They are much more likely to be aware of refactoring and expect it to just work. When I open the attached code in the editor, I see a red exclamation point with this note: as of release 5, 'enum' is a keyword and may not be used as an identifier (use -source 1.4 or lower to use 'enum' as an identifier.) This is only partially helpful: 1. The "-source 1.4" language is not meaningful to new users. To target them, the note should refer to project settings not command-line options. 2. It doesn't tell me that I have to change the source setting before I can use the rename action to rename 'enum' (and neither does the rename action).
*** Issue 121221 has been marked as a duplicate of this issue. ***
Resolving all issues with milestone "future" as LATER. If you feel strongly that it should be implemented please reopen and set the target milestone to "next".
NetBeans.org Migration: changing resolution from LATER to WONTFIX