Re: [picocontainer-dev] JSR330 work progress
Paul Hammant <[email protected]> Wed, 4 Aug 2010 06:35:52 -0500
| Newsgroups | gmane.comp.java.picocontainer.devel |
|---|---|
| Message-ID | <[email protected]> |
--00c09f8992270d7e7c048cfdd67f
Content-Type: text/plain; charset=ISO-8859-1
Kent,
Type is not generic, and has no defined behaviors:-
jhttp://
download-llnw.oracle.com/javase/1.5.0/docs/api/java/lang/reflect/Type.html
Yet class is generic, and implements Type :-
http://download-llnw.oracle.com/javase/1.5.0/docs/api/java/lang/Class.html
It's all messed up in Java since 5.0 :-(
Here's it getting worse:-
Class clazz = List<String>.class;
That does not compile. Even if it did it wouldn't be castable to class.
Then there's type erasure ( it'll be just List.class in bytecode ).
So we have a trick to allow us to survive type erasure:-
Type type = new Generic<List<String>>() {};
The inner class nature of this means that the super class has
Generic<List<String>> preserved in the bytecode. a convenient getter allows
us to extract that -> List<String> and Pico can use that for registration
and lookup.
- Paul
On Tue, Aug 3, 2010 at 1:02 PM, Kent R. Spillner <[email protected]> wrote:
> Hey, dude-
>
> > Because generic may not be a class. It may Type (which in itself
> > has no behaviors).
>
> Hrmmm... I need a bigger cluestick. When is a Java type not (ultimately) a
> class?
>
> Do you have a reference or a test case or an example you can pass along?
>
> Best,
> Kent
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
--00c09f8992270d7e7c048cfdd67f
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Kent,<div><br></div><div>Type is not generic, and has no defined behaviors:=
-</div><div>jhttp://<a href=3D"http://download-llnw.oracle.com/javase/1.5.0=
/docs/api/java/lang/reflect/Type.html">download-llnw.oracle.com/javase/1.5.=
0/docs/api/java/lang/reflect/Type.html</a>=A0</div>
<div><br></div><div>Yet class is generic, and implements Type :-=A0<a href=
=3D"http://download-llnw.oracle.com/javase/1.5.0/docs/api/java/lang/Class.h=
tml">http://download-llnw.oracle.com/javase/1.5.0/docs/api/java/lang/Class.=
html</a></div>
<div><br></div><div>It's all messed up in Java since 5.0 :-(</div><div>=
<br></div><div>Here's it getting worse:-</div><div><br></div><div>=A0=
=A0 Class clazz =3D List<String>.class;</div><div><br></div><div>That=
does not compile. =A0Even if it did it wouldn't be castable to class. =
=A0Then there's type erasure ( it'll be just List.class in bytecode=
).</div>
<div><br></div><div>So we have a trick to allow us to survive type erasure:=
-</div><div><br></div><div>=A0=A0Type type =3D new Generic<List<Strin=
g>>() {};</div><div><br></div><div>The inner class nature of this mea=
ns that the super class has Generic<List<String>> preserved in =
the bytecode. =A0a convenient getter allows us to extract that -> List&l=
t;String> and Pico can use that for registration and lookup.</div>
<div><br></div><div>- Paul</div><div><br><br><div class=3D"gmail_quote">On =
Tue, Aug 3, 2010 at 1:02 PM, Kent R. Spillner <span dir=3D"ltr"><<a href=
=3D"mailto:[email protected]">[email protected]</a>></span> wrote:<br><b=
lockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px =
#ccc solid;padding-left:1ex;">
Hey, dude-<br>
<div class=3D"im"><br>
> Because generic may not be a class. =A0It may Type (which in itself<br=
>
> has no behaviors).<br>
<br>
</div>Hrmmm... I need a bigger cluestick. =A0When is a Java type not (ultim=
ately) a class?<br>
<br>
Do you have a reference or a test case or an example you can pass along?<br=
>
<br>
Best,<br>
<font color=3D"#888888">Kent<br>
</font><div><div></div><div class=3D"h5"><br>
<br>
<br>
---------------------------------------------------------------------<br>
To unsubscribe from this list, please visit:<br>
<br>
=A0 =A0<a href=3D"http://xircles.codehaus.org/manage_email" target=3D"_bla=
nk">http://xircles.codehaus.org/manage_email</a><br>
<br>
<br>
</div></div></blockquote></div><br></div>
--00c09f8992270d7e7c048cfdd67f--