Bug 434580 - Incorrect unused import warning on static import
Summary: Incorrect unused import warning on static import
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.4   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: 4.5 M3   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2014-05-10 15:39 EDT by Alex W CLA
Modified: 2014-10-28 01:45 EDT (History)
3 users (show)

See Also:


Attachments
Example project with comment on line with incorrect warning (26.82 KB, application/zip)
2014-05-10 15:39 EDT, Alex W CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex W CLA 2014-05-10 15:39:24 EDT
Created attachment 242932 [details]
Example project with comment on line with incorrect warning

My apologies for being unable to isolate this behavior, but the problem doesn't seem to exist for Java's built-in libraries...

Essentially, I'm parsing some tokens, whose type is represented by an enum. I'm switching on the token's type, using a static import of the desired enum types so the switch would work (TokenType.____ is illegal, so static import fixes that).

Eclipse claims that the static import is unused, which means that when I organize imports the enum imports are removed, after which the compiler promptly complains about being unable to resolve the enum types.

Using javac with -Xlint:all gives no warnings, and in fact, javac doesn't require the static import at all, only that the other classes that I use are imported. The fact that TokenType is in the same package as my Token and Tokenizer class may have something to do with the reason that javac doesn't need the static import.

Attached is a short project which should demonstrate what I'm talking about. I'm on java 1.8_05, using Eclipse Luna M6.
Comment 1 Alex W CLA 2014-05-11 17:49:25 EDT
Turns out the problem was fixed in the newest build of Eclipse (20140508-1440)
Comment 2 Alex W CLA 2014-05-11 23:54:29 EDT
Reopened until the commit that fixed the issue is found (if necessary)
Comment 3 Srikanth Sankaran CLA 2014-07-21 01:46:47 EDT
Jay, please document the change that fixed this issue and resolve. TIA.
Comment 4 Jay Arthanareeswaran CLA 2014-07-31 01:51:14 EDT
(In reply to Alex W from comment #1)
> Turns out the problem was fixed in the newest build of Eclipse
> (20140508-1440)

Alex, can you tell me what you see fixed with this build? Between, 4.2, 4.3 and 4.4, I see no difference in behavior - i.e. warning issued on the static import, but removing the import doesn't cause any additional errors.
Comment 5 Jay Arthanareeswaran CLA 2014-08-05 02:56:33 EDT
Unlikely to include this in M1. Moving out.
Comment 6 Alex W CLA 2014-10-01 15:22:53 EDT
(In reply to Jayaprakash Arthanareeswaran from comment #5)
> Unlikely to include this in M1. Moving out.

Hmmm, seems I can't reproduce this after all. I don't know what happened...

My apologies for wasting your time.
Comment 7 shankha banerjee CLA 2014-10-28 01:42:48 EDT
Verified for 4.5 M3.