Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 360789 - Organize imports changes static imports to .* even when that introduces compile errors
Summary: Organize imports changes static imports to .* even when that introduces compi...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: 4.5 M6   Edit
Assignee: John Glassmyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 430303
  Show dependency tree
 
Reported: 2011-10-13 06:27 EDT by Jorn Hertsig CLA
Modified: 2015-03-18 02:59 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jorn Hertsig CLA 2011-10-13 06:27:17 EDT
Build Identifier: I20110613-1736

I have two enums with similarly named fields:
enum Horizontal {TOP, CENTER, BOTTOM}
enum Vertical {LEFT, CENTER, RIGHT}

I have code that uses them like this:

import Horizontal.TOP;
import Vertical.CENTER;

// in some method
setAlignment(TOP, CENTER);

I have the organize imports action configured to replace static imports with .* whenever there's 1 or more. (Window menu -> Preferences -> Java -> Code Style -> Organize Imports -> Number of static imports needed for .* = 1)

Now, organizing imports will change the imports to:
import Horizontal.*;
import Vertical.*;

Since Horizontal also offers a CENTER constant, my method call no longer compiles, since it expects an instance of Horizontal and one of Vertical, and it now gets two of Horizontal.

Reproducible: Always

Steps to Reproduce:
1. Organize imports in code and settings as described above
Comment 1 Remy Suen CLA 2011-10-13 07:48:20 EDT
Java tooling bugs go to JDT.
Comment 2 Jorn Hertsig CLA 2012-03-20 06:00:20 EDT
Thanks for moving this to the correct product, but is someone going to take a look at it?
Comment 3 Satyam Kandula CLA 2012-03-20 07:03:53 EDT
I confirm that this is a bug which needs to be fixed. However, we may not be able to look at this right now. Please feel free to contribute a patch.
Comment 4 Markus Keller CLA 2015-03-05 14:55:23 EST
Fixed via bug 430303.
Comment 5 shankha banerjee CLA 2015-03-18 02:59:19 EDT
Verified for 4.5 M6 with build I20150316-2000