Re: [Java Spec Report] Static contexts and local classes?
"Christopher Sahnwaldt" <[email protected]> Tue, 20 Apr 2004 00:40:17 +0200
| Newsgroups | gmane.comp.java.spec-report |
|---|---|
| Organization | http://freemail.web.de/ |
| Message-ID | <[email protected]> |
Hi, As this is not the first mail dealing with static context trouble, I thought I'd throw in my EUR 0,02... The trouble with the 'static' modifier in many of these examples is that in the declaration of inner classes its meaning is quite different than usual. (This is similar to the 'overloading' of the 'final' modifier for classes/methods on the one hand and for fields on the other.) If an inner class is not static, that simply means that instances of it have an implicit reference to an instance of the surrounding class. If it's static, that's not the case. Otherwise - mainly, as far as inheritance and access rules are concerned - the two behave the same. (Or do they? I'm not entirely sure. They should, anyway.) So, no matter if an inner class is static or not, its *declaration* is always associated not with an *instance* of its outer class, but with the outer class itself. I'd say the declaration could be considered as being (in) a static context, no matter what the modifier says. I feel that being aware of this makes things a little clearer for me. Don't know if I managed to get across what I mean... Bye, Christopher. [email protected] schrieb am 15.04.04 16:37:15: > > Yes, it is well-formed. This is compiler bug 4994261. > > Roly Perera wrote: > > Hi, > > > > Is the following well-formed? > > > > class Test2<A, B> > > { > > } > > > > public class Test > > { > > public static class Y<T, U> > > { > > void f () > > { > > class X extends Test2<T, U> // static context? > > { > > } > > } > > } > > } > > > > > To unsubscribe from this mailing list, send an email to: > [email protected] > > Yahoo! Groups Links > > > > > 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/