Community
Participate
Working Groups
[1.5] The compiler should error on ambiguous method invocation due to duplicate static imports. The example below compiles without error. Eclipse just binds m() to the first static import that provides a matching method declaration. Javac errors at the invocation of m(). --- p/A.java: -------------------------------- package p; import static x.X.m; import static p.A.m; public class A { public static void main(String[] args) { new B().use(); } public static void m() { System.out.println("A.m()"); } public static void m(int arg) { System.out.println("A.m(" + arg + ")"); } } class B { void use() { m(); // javac: reference to m is ambiguous, // both method m() in x.X and method m() in p.A match m(1); } } --- c/X.java: -------------------------------- package x; public class X { public static void m() { System.out.println("X.m()"); } }
Added StaticImport test024
Verified in I20050215-2300