Re: Reflecting generics
- From: Domagoj Klepac <no.spam.sent.2.domchi@xxxxxxxxxxxxxxx>
- Date: Fri, 31 Mar 2006 17:11:10 +0200
On Fri, 31 Mar 2006 06:10:17 -0800, "Adam Maass"
<adam.nospam.maass@xxxxxxxxxxx> wrote:
I'm wondering if this is possible - and after much digging, it seems
that it isn't. I have the following piece of code:
ArrayList<String> stringArray = new ArrayList<String>();
Class c = stringArray.getClass();
Is it possible to, somehow, get "java.lang.String" from c?
Or is that information lost after compiling?
Generics are implemented by "type erasure." At runtime, any reference to
"java.lang.String" is long-since gone, so it can't be returned by any
reflective method.
Thought so. Adam, thanks for clarification.
Domchi
.
- References:
- Reflecting generics
- From: Domagoj Klepac
- Re: Reflecting generics
- From: Adam Maass
- Reflecting generics
- Prev by Date: Re: volatile
- Next by Date: Re: Don't you need an XML Virtual Machine ?
- Previous by thread: Re: Reflecting generics
- Next by thread: Re: Reflecting generics
- Index(es):
Relevant Pages
|