Bug 81718

Summary: [1.5] "Static import never used" warning disappears when variable of same name is declared
Product: [Eclipse Project] JDT Reporter: Ingo Maier <i.maier>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: minor    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M5   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Ingo Maier CLA 2004-12-21 04:43:13 EST
import static java.lang.Math.PI;

public class Foo {}

gives a warning, that the static import is never used (OK). If you declare a PI,
the warning disappears (not OK):

import static java.lang.Math.PI;

public class Foo {
  boolean PI;
}

It seems that it does not matter where such a variable is declared in the
compilation unit the warning always disappears.

Note: you can use PI from Math in a different scope (OK):

import static java.lang.Math.PI;

public class Foo {
  double d = PI; // from Math

  void f() {
    boolean PI;
  }
}

class Bla {
  double d = PI; // from Math
}
Comment 1 Philipe Mulet CLA 2005-01-04 05:19:09 EST
The field hiding detection support is causing the unused import to be used.
Comment 2 Philipe Mulet CLA 2005-01-04 05:23:07 EST
Fixed along with bug 81724.
Comment 3 Philipe Mulet CLA 2005-01-04 05:23:44 EST
Added regression test: StaticImportTest#test019.
Fixed
Comment 4 Jerome Lanneluc CLA 2005-02-15 05:23:42 EST
Verified in I20050214