RE: [Java Spec Report] reference to nonstatic type from static context
"Roly Perera" <[email protected]> Sun, 4 Apr 2004 09:43:16 +0100
| Newsgroups | gmane.comp.java.spec-report |
|---|---|
| Organization | Ergnosis Ltd |
| 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";
> }
> }
> }
I've only recently started looking at generics so apologies in
advance...
I would naively expect b.t to be of type T, and for T to be in scope
despite the static boundary between A and C. Clearly I'm wrong.
Roly
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.590 / Virus Database: 373 - Release Date: 16/02/2004
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/