Matthew Cox wrote:You can't cast to it at Compile time if I am understanding your question correctly. When using Reflection, you are essentially giving up compile-time type checking and all the conveniences that come with it in order to gain the ability to "dynamically cast" as people seem to always describe it. Read up on Reflection and examine some coding examples. Reflection is tedious, run-time error prone (if not carefully coded), and if I remember correctly ... has a lot of overhead associated with it (not sure on this one). So be careful about how and when you decide to use it.
Someone in an earlier post mentioned a much simplier design ... it won't scale well but if you are only handling 4 or 5 classes and interfaces tops ... then creating a switch block of if block and using instanceof would be the best (meaning easiest) route. =D
GL