Re: Reflecting generics
- From: "Adam Maass" <adam.nospam.maass@xxxxxxxxxxx>
- Date: Fri, 31 Mar 2006 06:10:17 -0800
"Domagoj Klepac" 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.
-- Adam Maass
.
- Follow-Ups:
- Re: Reflecting generics
- From: Domagoj Klepac
- Re: Reflecting generics
- References:
- Reflecting generics
- From: Domagoj Klepac
- Reflecting generics
- Prev by Date: Re: volatile
- Next by Date: Re: volatile
- Previous by thread: Reflecting generics
- Next by thread: Re: Reflecting generics
- Index(es):