Vishal Kumar Aruru wrote:
But here my scenario is different, when i use method.invoke() function it returns an object, which i don't want this. My function returns a list of classes. So, when i use method.invoke() function, i need to typecast the list of the classes. but i will get the class name dynamically, so how to use this for a generic way.
It doesn't matter if your function returns a list of classes. A "list of classes" IS-A object. Heck, it doesn't even matter if the method returns primatives (which aren't objects). The invoke() method will box any primitives returns for you, and hence, the return IS-A object.
Another reflection items which may help. The Method object has a method that tells you what is the type being returned.
Henry