geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kresten Krab Thorup (Trifork)" <k...@trifork.com>
Subject Re: Anyway to get the generic type from a generic class?
Date Tue, 02 Oct 2007 08:04:37 GMT
Yes, this is quite unfortunate, and I can tell you that this is one  
of the issues where there was much discussion in the EG and in the  
groups of people trying to influence JSR 14.  The bottom line is that  
the chosen implementation of generics works without any changes to  
the JVM, and that code compiled with generics could theoretically be  
run with and older JVM.  In practice this kind of backwards  
compatibility doesn't work anyway because of the bytecode version  
burned into class files by a JDK 1.5 compiler.  But as allways these  
decisions are piled up agains a lot of different technical as well as  
political issues...

Kresten


On Oct 1, 2007, at 8:11 AM, Jason Dillon wrote:

> Alright... thanks, that is what I figured :-(  So lame... I can  
> figure out that a class as T and E bound, but I can't figure out  
> the type of those buggers... so stupid :-(
>
> --jason
>
>
> On Sep 30, 2007, at 11:08 PM, David Jencks wrote:
>
>>
>> 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 :-)
>>
>> sorry
>> david jencks
>>
>>>
>>> --jason
>>
>

Kresten Krab Thorup, Ph.D.
CTO, Trifork

                 WHO'S AT JAOO? - http://jaoo.dk
-----------------------------------------------------------------------
Trifork A/S, Margrethepladsen 3, 8000  Ã…rhus C, Denmark
Tel: +45 8732 8787 / Fax: +45 8732 8788 / Mob: +45 2343 4626




Mime
View raw message