Bug 6977 organize imports imports unnecessary classes
I'm talking about integration build of December 11: Here is a code (for jdk1.4): ------------ import java.io.IOException; public class test1 { static Thread thr = new Thread() { public void run() { System.out.println("Shutting down"); try { int c = System.in.read(); System.out.println(c); } catch (IOException e) { } } }; int o = 5; /** * Method main. * * @param args */ public static void main(String[] args) { Runtime r = Runtime.getRuntime(); r.traceInstructions(true); r.traceMethodCalls(true); r.addShutdownHook(thr); System.out.println("Available procs: " + r.availableProcessors ()); System.out.println("Free Memory: " + r.freeMemory()/1024 + "Kb"); System.out.println("Total Memory: " + r.totalMemory()/1024 + "Kb"); System.out.println("Max Memory: " + r.maxMemory()/1024 + "Kb"); System.getProperties().list(System.out); try { System.in.read(); } catch (Exception e) { } } } ---------- end of example code ------ Pressing CTRL+SHIFT+O to organize imports adds the following two imports: import sun.security.krb5.internal.r; import sun.security.krb5.internal.crypto.c; for the "c" and "r" VARIABLES!. This is a bad bad thing...... Surprisingly it skips the "o" field....
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest.java
}
	protected void setUp() throws Exception {
		fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
		assertTrue("rt not found", JavaProjectHelper.addRTJar(fJProject1) != null);
		File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC);
		assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
		ZipFile zipfile= new ZipFile(junitSrcArchive);
		JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", zipfile);
	}
	protected void tearDown() throws Exception {
		JavaProjectHelper.delete(fJProject1);
	}
	
	private IChooseImportQuery createQuery(final String name, final String[] choices, final int[] nEntries) {
		return new IChooseImportQuery() {
			public TypeInfo[] chooseImports(TypeInfo[][] openChoices, ISourceRange[] ranges) {
				assertTrue(name + "-query-nchoices1", choices.length == openChoices.length);
				assertTrue(name + "-query-nchoices2", nEntries.length == openChoices.length);
				if (nEntries != null) {
					for (int i= 0; i < nEntries.length; i++) {
						assertTrue(name + "-query-cnt" + i, openChoices[i].length == nEntries[i]);
					}
				}
				TypeInfo[] res= new TypeInfo[openChoices.length];
				for (int i= 0; i < openChoices.length; i++) {
					TypeInfo[] selection= openChoices[i];
					assertNotNull(name + "-query-setset" + i, selection);
					assertTrue(name + "-query-setlen" + i, selection.length > 0);
					TypeInfo found= null;
					for (int k= 0; k < selection.length; k++) {