geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <>
Subject Re: Anyway to get the generic type from a generic class?
Date Mon, 01 Oct 2007 06:08:03 GMT

On Sep 30, 2007, at 10:48 PM, Jason Dillon wrote:

> Any of you generics experts out there know if there is any way to  
> get the generic type from a generic class... like, say you have:
>     Class type = new ArrayList<String>().getClass();
> Is there any way to determine that this is an ArrayList containing  
> String objects?  I can't seem to figure out how to get this  
> information out of the Class instance.  I can figure out what the  
> type variable name was, er like T, but that is well, completely  
> useless IMO.
> Does anyone know if its possible and how to do it?

I spent a couple days reading up on generics and trying stuff and  
concluded it was not possible.  There are some statements in the book  
on generics that confirm this.  Hopefully you will find a way to  
prove I'm wrong 'cause it sure would be handy :-)

david jencks

> --jason

View raw message