This site is maintained for archival purposes only. Eclipse projects have transitioned to GitHub and Eclipse GitLab. Use the Projects search tool to locate your project and access its latest code and issue tracker.
Bug 477597 - Wrong unused import warning
Summary: Wrong unused import warning
Status: CLOSED DUPLICATE of bug 534865
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.5   Edit
Hardware: PC All
: P3 normal with 2 votes (vote)
Target Milestone: 4.10 M3   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-16 11:11 EDT by Gilles Duboscq CLA
Modified: 2020-02-27 17:14 EST (History)
1 user (show)

See Also:


Attachments
project (2.87 KB, application/zip)
2015-09-16 11:11 EDT, Gilles Duboscq CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gilles Duboscq CLA 2015-09-16 11:11:53 EDT
Created attachment 256618 [details]
project

With the following code:
C.java------
package b;

public enum C {
    d,
    e
}
------------
B.java------
package b;

import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

@Target(ElementType.FIELD)
public @interface B {
    C value();
}
------------
A.java------
package a;

import static a.A.Inner.ONE;

import b.B;
import b.C;

public final class A {
    public static class Inner {
        @B(C.d) public static final int ONE = 1;
    }

    public static int foo() {
        return ONE;
    }
}
------------

There is a warning ("The import x is never used") on the imports for b.B and b.C.
These warnings are incorrect since if those imports are removed the compilation fails since both B and C are used in the inner class (A.Inner).
Note that replacing "import static a.A.Inner.ONE" with "import static a.A.Inner.*" makes the warnings go away.

A zipped project containing the same files is attached.

I initially thought that this might be the same as bug 414423, however I could not reproduce bug 414423.
Comment 1 Eclipse Genie CLA 2020-02-12 18:04:19 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 2 Stephan Herrmann CLA 2020-02-27 17:14:09 EST
This has been fixed in 4.10, most likely via bug 534865

*** This bug has been marked as a duplicate of bug 534865 ***