Community
Participate
Working Groups
Extracting to method the code in between /*START*/ and /*END*/ results in invalid source: package p1; import java.io.*; public class X { void foo(final int out){ int i; if (out > 5){ /*START*/i = 1;/*END*/ } else { i = 2; } i++; } } =====> package p1; import java.io.*; public class X { void foo(final int out){ int i; if (out > 5){ i = asd(i); // COMPLAINS THAT VARIABLE 'i' MAY NOT HAVE BEEN INITIALIZED - diagnosis is correct } else { i = 2; } i++; } protected int asd(int i) { i = 1; System.out.println(i); return i; } } NOTES: DB (06.06.2001 14:23:42) The only way to fix this is to generate the extracted method as follows: protected int asd() { return 1; } Impact of this fix on extract method is high, since we have to do some analysis for the extracted method. Opt to not fix this for June.
moved to 'active'
PRODUCT VERSION: SDK 119
works for me in the latest
20020115: Now, by extracting "i = 1;" I get package p1; import java.io.*; public class X { void foo(final int out){ int i; if (out > 5){ asd(); } else { i = 2; } i++; } protected void asd() { int i; i = 1; } } asd() doesn't do anything useful and it changes the behaviour of foo.
See previous comment
Fixed in build > iX-20021115