Re: Reflecting generics



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
.



Relevant Pages

  • Re: Read what you type
    ... someone's acquaintance with scholarship while acknowledging that you don't know them from Adam. ... You're back to talking nonsense again Pete!! ... thought that somehow you had managed to unleash the forces of darkness upon him, I was dreading the knock in the night that would indicate the long reach of your mighty arm. ...
    (rec.sport.rugby.union)
  • Re: A glimpse into the Void...
    ... :>> tidbits o' trivia from Adam, such as he hawks ladies purses and lovingly ... :>> tends to flowers. ... Somehow you bring out his more feminine side. ... :> There is much more to Adam than meets the eye here on scs. ...
    (soc.culture.scottish)
  • Re: SP2 - longggggggg, slowwwww, shutdown
    ... my suspicion is that Prefetch is somehow involved, ... not sure why, how, or the fix. ... >adam wrote: ... >> SP2 seems to be running fine, but it is taking up to three ...
    (microsoft.public.windowsxp.general)
  • Re: A glimpse into the Void...
    ... :> tidbits o' trivia from Adam, such as he hawks ladies purses and lovingly ... :> tends to flowers. ... Somehow you bring out his more feminine side. ... :There is much more to Adam than meets the eye here on scs. ...
    (soc.culture.scottish)
  • Re: A glimpse into the Void...
    ... :> tends to flowers. ... Somehow you bring out his more feminine side. ... :There is much more to Adam than meets the eye here on scs. ...
    (soc.culture.scottish)