Bug 306568

Summary: [ImportRewrite] Add Import does not work for nested type when package is on-demand imported
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jarthana, Olivier_Thomann
Version: 3.6   
Target Milestone: 3.6 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 306571    
Attachments:
Description Flags
Proposed fix none

Description Markus Keller CLA 2010-03-19 14:34:59 EDT
HEAD

- default Organize Imports settings
- have this CU:

package xy;

import java.util.*;

public class Try {
    public static void main(String[] args) {
        HashMap h;
        
        Map.Entry e= null;
        Entry e2= null;
        
        System.out.println("hello");
    }
}

- set caret into "Entry" on the line with the compile error
- Source > Add Import
=> expected: "import java.util.Map.Entry;" should be added
=> was: no change

I think the problem is that java.util.Map.Entry now belongs to the java.util group, but that should only be relevant for grouping, but it doesn't mean that java.util.* actually imports java.util.Map.Entry.
Comment 1 Olivier Thomann CLA 2010-03-30 13:35:01 EDT
Created attachment 163430 [details]
Proposed fix
Comment 2 Olivier Thomann CLA 2010-03-30 15:30:07 EDT
Released for 3.6M7.
Markus, let me know if you find anything wrong. Besides the awkward use of the old behavior, it seems to work as expected.
Comment 3 Olivier Thomann CLA 2010-04-14 09:04:40 EDT
Added regression test:
org.eclipse.jdt.core.tests.rewrite.describing.ImportRewriteTest#testAddImports6
Comment 4 Jay Arthanareeswaran CLA 2010-04-27 10:40:52 EDT
Verified for 3.6M7 using build I20100424-2000.