|
From: Colin S. <col...@ex...> - 2005-10-23 12:22:55
|
My understanding is that Generics-based types map to completely standard
(non-Generics) byte code for those types. So if you have a List<String>
and you pass that to somebody, at the bytecode level it's a completely
normal List. This is part of the reason why Generics in Java are
somewhat half-assed; some of the limitations could have been removed if
the basic class related bytcode had had enhancements to support some
concepts needed for templating.
Here's some info on this aspect:
http://www.langer.camelot.de/GenericsFAQ/FAQSections/TechnicalDetails.html#How%20does%20the%20compiler%20translate%20Java%20generics?
On the other hand, when it comes to method signatures, my understanding
is that the bounding information is available through reflection. So you
can tell that a method takes a List<String> and not a List. I'm not 100%
sure on this (and confirmation by anybody would be good), but I presume
this is what Rob is basing his statement below on.
Regards,
Colin
Peter Backlund wrote:
>On Sat, 2005-10-22 at 16:52 +0100, Rob Harrop wrote:
>
>
>>That's not a bad idea - can you raise an JIRA issue for this? Also, in
>>Spring 1.3 we will actually autodetect the element types when using
>>generics definitions like you have here so you won't need to specify the
>>element types.
>>
>>
>
>Sure, but would that really be necessary if you can autodetect it in
>1.3? Besides, is it possible to detect generics definitions in bytecode?
>I was under the impression that it wasn't possible, or will it require
>processing of the corresponding source code?
>
>/Peter
>
>
>
>>Rob
>>
>>Peter Backlund wrote:
>>
>>
>>
>>>Hello.
>>>
>>>Would it make sense to add key-class and value-class attributes to the
>>><map> element, and feed the strings in the key/value elements (or
>>>attributes) to the appropriate PropertyEditor, to allow setting key and
>>>value of the correct class when using maps with generics?
>>>
>>>For example, consider this example:
>>>
>>>public Map<Locale, String> getHeadsOfState() { ... }
>>>
>>>configured like this:
>>>
>>><property name="headsOfState">
>>> <map key-class="java.util.Locale" value-class="java.lang.String">
>>> <entry key="en_US" value="George W. Bush"/>
>>> <entry key="en_GB" value="Tony Blair"/>
>>> <entry key="sv_SE" value="Göran Persson"/>
>>> </map>
>>></property>
>>>
>>>I've glanced at modifying the xml parsing and subclassing or modifying
>>>MapFactoryBean, but I thought I'd ask here first if it's possible to do
>>>this any other way, or if it's a bad idea altogether.
>>>
>>>What do you think?
>>>
>>>/Peter Backlund
>>>
>>>
>>>
>>>
>>>
>>>-------------------------------------------------------
>>>This SF.Net email is sponsored by:
>>>Power Architecture Resource Center: Free content, downloads, discussions,
>>>and more. http://solutions.newsforge.com/ibmarch.tmpl
>>>_______________________________________________
>>>Springframework-developer mailing list
>>>Spr...@li...
>>>https://lists.sourceforge.net/lists/listinfo/springframework-developer
>>>
>>>
>>>
>>>
>
>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by the JBoss Inc.
>Get Certified Today * Register for a JBoss Training Course
>Free Certification Exam for All Training Attendees Through End of 2005
>Visit http://www.jboss.com/services/certification for more information
>_______________________________________________
>Springframework-developer mailing list
>Spr...@li...
>https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
>
>
|