Re: [Java Spec Report] reference to nonstatic type from static context

Neal Gafter <[email protected]> Sun, 04 Apr 2004 00:03:47 -0800
Newsgroups gmane.comp.java.spec-report
Message-ID <[email protected]>
Roly Perera wrote:
> At first glance that sounds like a mistake in the JLS.  The constraint
> should only apply to uses of non-static methods and fields.
> 
> The rationale I think is that to *name* an inner class one does not need
> an instance of its enclosing class, although to *construct* one, one
> does.

With the advent of generics, this is no longer true.


class A<T> {
     class B {
         T t;
     }
     static class C {
         B b = null;
         {
             // what is the type of b.t?
             b.t = "foo";
         }
     }
}



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/