Project: JDT
Bug 159424 [organize imports] Organize Imports creates invalid static import
Reported: 2006-10-01 19:42:57 | Status: resolved fixed

When a class (A) defines a static field (logger) and an inner class (BSubClass) uses it when it's superclass (B) has a static field of the same name, running organize imports on A adds an invalid entry (import static a.A.logger;). a/A.java: package a; import java.util.logging.Logger; public abstract class A { private static Logger logger = Logger.getLogger(A.class.getName()); private BSubClass b; public A() { b = new BSubClass(); b.someMethod(); } protected class BSubClass extends B { public void someMethod() { logger.info("someMethod() called in BSubClass"); } } } a/B.java package a; import java.util.logging.Logger; public abstract class B { private static Logger logger = Logger.getLogger(B.class.getName()); } I've found that the bug does not occur when A is in the default package. An easy workaround is to remove the import after it is generated, but this becomes tedious.

Files changed in fix:
org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/ImportReferencesCollector.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/ScopeAnalyzer.java