>
>
> Reflection can be valuable and it does have a use, particularly if you're
>> running up against limits of the Java type system (e.g. you need an API that
>> can work on *any* object exposing a `close` method), or perhaps need to
>> implement some custom serialisation of objects from a third party library.
>>  It's still backdoor trickery, but it's backdoor trickery in the face of no
>> other possible alternative...
>>
>>
> Tahts not a limit of the type system the problem is there was no Closable
> from the beginning.
>
> Conceptually, there's a "has close method" type, but there's no way of
representing this in Java.  To be fair, there's usually not a way to
represent this in most statically typed languages, and no need to represent
it in a dynamically typed language.

If you want something that *is* possible within the type system, but becomes
so unwieldy  that you'd never actually want to do it (you'd use reflection
instead), take a look at this article:
http://apocalisp.wordpress.com/2008/10/23/heterogeneous-lists-and-the-limits-of-the-java-type-system/

<http://apocalisp.wordpress.com/2008/10/23/heterogeneous-lists-and-the-limits-of-the-java-type-system/>
-- 
Kevin Wright

mail / gtalk / msn : [email protected]
pulse / skype: kev.lee.wright
twitter: @thecoda

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to