Community
Participate
Working Groups
Since 1.3 it is no longer 'allowed' to work with classes in the 'default' package. (i.e no package declaration). As a consequence eclipse no longer allows imports from such packages and removes them whenever an 'organize import' is requested. Our project (real-time lightweight small memory-print) is based on a JVM that has been developed in-house an is based on 1.1.8. And yes.. there are classes that are in the default package. There is one class (orb) in particular that is used in about 60% of all our classes. It very annoying that eclipse automatically removes the import orb; statement from all these classes. You don't even have to call a organize import. If you do a code completion that adds a new import statement, this will also remove the very important import statement. PLease, please supply an option in the preferences to prevent the clean up of these imports. Many thanks.
Which build are you using? It's the other way round: So far Eclipse never added imports to types in default package, since some weeks ago it does. We don't force any 1.4 compatibility with organize imports (I thought it was 1.4 , not 1.3 which has the new rule), you will have to fix your code anyways if you use classes in the default packages and want to run on 1.4. If you are already using the latest integration builds (> M3), and still have the problem, please reopen the bug with some steps.
1) You're right it is 1.4 which has the new rule.. not 1.3 2) We are working with 1.1.8 and we'll never move to 1.4. As stated before, i'm working on a home-made JDK pased on 1.1.8. We don't plan to rewrite this JVM. 3) It is still in M3 (which i'm using now).. But has not always been there. Somewhere will making 2.0 this 'feature' slipped in. Maybe a didn't express myself very clear.. i'll do it again with an example Step 1. Create a class in the default package ---- public class DefaultClass { } Step 2. Create some class using that defaultClass --- package myPack; import DefaultClass; public class AClass { public static void main(String[] args) { DefaultClass defaultClass = new DefaultClass(); } } ------ Step 3a. (Manual way) On the AClass perform a Organize Imports. -> It will remove the line "import DefaultClass" -> as a result AClass has compiler errors. Step 3b (Indirect way) Place your cursor somewhere in the main Class. Type 'Colo' and press Ctrl+Space to call code completion. Select java.awt.Color. The line 'import java.awt.Color' is added, and at the same time the line 'import DefaultClass' is removed. Bug 3a, is not so annoying since i don't often call 'organize imports' Bug 3b, though is worse since i use codecompletion very often to added never used Class references..
The feature is in the latest integration build (not yet in M3). I tested your scenario, it works now!
I just checked with Version: 2.1 Build id: 200212041234 ---- The bug is indeed fixed, but not perfect. What i get when i do organize imports is that import DefaultClass; is replaced by import.DefaultClass; //A dot is added!! Minor bug.. we're almost there.