| Summary: | [clean up] 'Add final to local variables' only works if initialized at declaration | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Brian Miller <Brian.Miller> |
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | markus.kell.r, numeralnathan |
| Version: | 3.5 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | stalebug | ||
The 'Add final modifier to local variables' clean up currently only works if the variable is initialized at the declaration (and not written later). Fixing this would need much more analysis. From bug 272532 comment 3: > To be honest, that whole clean up should be rewritten to just > - create a working copy with all supported variables set to final > - compile the working copy > - create changes for those variables which didn't introduce a definite > assignment problem With HotSpot 7u1, declaring a local variable or parameter final does *not* have a performance impact. The optimizer is able to do all of the optimizations with or without the final keyword. Declaring a field final *does* have a performance impact. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |
Build Identifier: 20090920-1017 class Bug { void method(){ String value; if(equals(this)) { value=""; } else { value=""+this; } value.toString(); } } Reproducible: Always Steps to Reproduce: 1. Configure the Java>Editor>SaveActions preference to include "Add final modifier to local variables". 2. Add some irrelevant whitespace to class Bug's editor. 3. Save class Bug's change. See that variable 'value' was wrongly not automatically declared final.