Community
Participate
Working Groups
Trying to inline variable cca in the following code works incorrectly as described. Complete eclipse project is available here: https://github.com/teosoft123/eclipse-inline-variable-refactoring-bug-demo.git ========= Details =========== public class InlineBugDemo { String parameter; /** * Inline variable refactoring bug demo: * 1. Select variable cca * 2. Press Option+Command+I for "inline variable" * 3. The prompt dialog will show "Inline 2 occurences of local variable cca?" * 4. Hit "Enter" to proceed. Result will create two *instances* of the class CreateConnectionAsync as following: * * new CreateConnectionAsync().execute(new String[] {parameter}); * Connection<String> connection = new CreateConnectionAsync().get(); * */ public void refactorMe() { CreateConnectionAsync cca = new CreateConnectionAsync(); cca.execute(new String[] {parameter}); Connection<String> connection = cca.get(); }
Move to JDT/UI for comment.
Just tested it on Windows 8, eclipse 3.8.1, x64 JDK 1.6.0_16. Same problem. Don't see how to add other platforms to the same bug.
Inlining a local variable always bears the risk of performing the side effects of its initialization more than once. 1. how is your example different from any other scenario with side effects in the local's initialization? 2. what do you expect the refactoring to produce?
*** This bug has been marked as a duplicate of bug 349276 ***