And actually IDEs like Eclipse or IntelliJ even offer to reorganize individual imports into star imports (I think IntelliJ does this as default).
Today I was doing a bigger refactoring and was moving packages around.
Eclipse is doing a really good job here.
Unfortunately I was getting compile errors afterwards, because the old packages did no longer exist.
The reason behind this is that a refactoring is a textual replacement and not a semantical. Example:
import foo.*;
public class Bar {
Foo f;
}
Now you move foo.Foo to baz.Foo. Eclipse adds the new import baz.Foo statement, but does not remove
foo.*, as is does basically not know that foo.* no longer exists (it could analyze all statements in the class and
automatically remove unused imports afterwards though).
1 comment:
Thanks, this helped me to realise, why star imports are bad (doing code review now).
Post a Comment