[Java Spec Report] static import question

"Timothy Hanson" <[email protected]> Fri, 19 Mar 2004 15:38:58 -0800
Newsgroups gmane.comp.java.spec-report
Message-ID <[email protected]>
In the example below, Test imports method m1 via a single static import, and there is also an m1 in T2 that is imported via a static import on-demand. Is the invocation of m1() with no arguments ok?

In the spec section 7.5.3 para 3, it says: "A single-static import declaration d in a compilation unit c of package p that imports a member named n shadows the declaration of any static member named n imported by a static import-on-decmand declaration in c, throughout c."

To me this implies that T2.m1 shadows T1.m1, even though T2.m1() is not applicable.

Thanks,
Tim


--- File Test.java ----

package p1;
import static p1.T1.*;
import static p1.T2.m1;

public class Test {
   void foo() {
      m1(); // <-- is this an error?
   }
}

--- File T1.java ---

package p1;

public class T1 {
   public static void m1();
}

--- File T2.java ---

package p1;
public class T2 {
   public static void m1(int i) {}
}


To unsubscribe from this mailing list, send an email to:
[email protected]
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/java-spec-report/

<*> To unsubscribe from this group, send an email to:
     [email protected]

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/