Project: JDT
Bug 200698 [introduce factory] 'method already exists' test is to unprecice
Reported: 2007-08-21 11:03:43 | Status: resolved fixed

Build ID: I20070625-1500 Given the following class: public class IntroduceFactory { final long l; public IntroduceFactory(int i) { this.l = i; } public IntroduceFactory(long l) { this.l = l; } } If I introduce default factory methods for the contructors the result is following: public class IntroduceFactory { public static IntroduceFactory createIntroduceFactory(int i) { return new IntroduceFactory(i); } public static IntroduceFactory createIntroduceFactory(long l) { return new IntroduceFactory(l); } final long l; private IntroduceFactory(int i) { this.l = i; } private IntroduceFactory(long l) { this.l = l; } } However if I want to just call the factory method "create" like this: public class IntroduceFactory { public static IntroduceFactory create(int i) { return new IntroduceFactory(i); } final long l; private IntroduceFactory(int i) { this.l = i; } public IntroduceFactory(long l) { this.l = l; } } then I am not allowed to introduce factory method for the last constructor (long parameter) because "duplicate method name:create".

Files changed in fix:
org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceFactoryRefactoring.java