Project: JDT
Bug 219204 [clean up] Remove static accesses through instances may remove code with side-effects
Reported: 2008-02-15 19:15:33 | Status: verified fixed

Make sure Member Accesses --> Change all accesses through instances is selected for Clean Up. Consider the following example: package org.example; public class Thing { public static void main(final String[] args) { Thing.returnThing().returnThing().returnThing(); } public static Thing returnThing() { return new Thing(); } } Running Clean Up reduces this to (Note the missing returnThing() invocations.) package org.example; public class Thing { public static void main(final String[] args) { Thing.returnThing(); } public static Thing returnThing() { return new Thing(); } } thus removing valid code. I ran into this while using commons-cli's BuildOption and Clean Up completely broke my program.

Files changed in fix:
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CodeStyleFix.java