Project: JDT
Bug 150481 [clean up] Removing qualified this expressions may change semantic
Reported: 2006-07-13 04:01:13 | Status: verified fixed

Hi! I just tried the new "Clean Up" feature and I found the following problem. Try to use it on this code and you'll find that it "cleans" up the code in a wrong way. --- public class Test { public Test() { doTest(); } public synchronized void doTest() { System.out.println("doTest started"); (new Inner()).start(); try { wait(); } catch(InterruptedException e) { e.printStackTrace(); } System.out.println("doTest finished"); } private class Inner extends Thread { @Override public void run() { try { Thread.sleep(2000); } catch(InterruptedException e) { e.printStackTrace(); } synchronized(Test.this) { Test.this.notifyAll(); } } } public static void main(final String[] args) { new Test(); } } --- The problem is with the option "Use 'this' qualifier for method access" set to "Only if necessary": it removes the "Test.this." qualifier... but the result is not lexically the same as the original code. I hope to have been of help. Mauro.

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