I've an array of beans and use reflection to retrieve the values within them through their getter methods. All the beans are of the same type, so instead of using reflection for every object, is there any way of generating code(or object) which will have the calls and I can regenerate this object for a different type of bean? I've heard of something like this in Lisp macros, is it possible in Java?
3 Answers
Generics may help you in reducing code repetition before you compile and release the class.
You can also compile and deploy class at run-time, see How can I compile and deploy a java class at runtime?