Project: JDT
Bug 149316 [move method] Move method refactoring does not handle parameters correctly
Reported: 2006-06-30 12:13:40 | Status: verified fixed

In the two following examples, the resulting java source code after applying "Refactor"->"Move..." to method 'participates' (taking the default values by just klicking OK) is not behaviour preserving. First example: Before: package noarray; public class Person { int id; boolean participates(Project p) { return (p.participant.id == id); } } package noarray; public class Project { Person participant; } After: package noarray; public class Person { int id; } package noarray; public class Project { Person participant; boolean participates(Person person) { return (participant.person.id == person.id); } } Correct would have been:return (participant.id == person.id); Second example (the same with an array): Before: package array; public class Project { Person[] participants; } package array; public class Person { int id; boolean participates(Project p) { return (p.participants[0].id == id); } } After: package array; public class Person { int id; } package array; public class Project { Person[] participants; boolean participates(Person person) { return (person.id == person.id); } } Correct would have been:return (participants[0].id == person.id); (This bug is not new to Eclipse 3.2, but was already in 3.1. IIRC 3.0 was not affected. Set severity to major, because refactoring support needs to be rock solid.)

Files changed in fix:
org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test39/in/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test39/in/B.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test39/out/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test39/out/B.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test40/in/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test40/in/B.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test40/out/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test40/out/B.java org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInstanceMethodTests.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveInstanceMethodProcessor.java