U
u.Shanker
Hello !
Ok. I did my homework, by readin around, but not able to make it generic.
Problem:
I have to call ExternalClass.myMethod(InputClass[]);
Now depending on the cases InputClass and myMethods are different.
So I want to reflection.
Solution:
ExternalClass external = ...
InputClass rr = .....
InputClass[] array = new InputClass[] { rr };
GenerateProtocolObject generator = new GenerateProtocolObject(); // does the
Class.forName(classname)
Object o =generator.getObjectInstance("InputClass");
Class cls = Class.forName("InputClass");
Object arr = Array.newInstance(cls, 1); // just trying with 1 element in
array
Array.set(arr, 0, o);
Class c = external.getClass();
Class[] parameterTypes = new Class[] {array}; // <-- this works
Method concatMethod;
Object[] arguments = new Object[] { };
try {
Method[] mm = c.getMethods();
concatMethod = c.getMethod("myMethod", parameterTypes);
--
but I want something like
Class[] parameterTypes = new Class[] {o.getClass()};
Class[] parameterTypes = new Class[] {o[]};
Class[] parameterTypes = new Class[] {arr};
thanks for any comments
uma
Ok. I did my homework, by readin around, but not able to make it generic.
Problem:
I have to call ExternalClass.myMethod(InputClass[]);
Now depending on the cases InputClass and myMethods are different.
So I want to reflection.
Solution:
ExternalClass external = ...
InputClass rr = .....
InputClass[] array = new InputClass[] { rr };
GenerateProtocolObject generator = new GenerateProtocolObject(); // does the
Class.forName(classname)
Object o =generator.getObjectInstance("InputClass");
Class cls = Class.forName("InputClass");
Object arr = Array.newInstance(cls, 1); // just trying with 1 element in
array
Array.set(arr, 0, o);
Class c = external.getClass();
Class[] parameterTypes = new Class[] {array}; // <-- this works
Method concatMethod;
Object[] arguments = new Object[] { };
try {
Method[] mm = c.getMethods();
concatMethod = c.getMethod("myMethod", parameterTypes);
--
but I want something like
Class[] parameterTypes = new Class[] {o.getClass()};
Class[] parameterTypes = new Class[] {o[]};
Class[] parameterTypes = new Class[] {arr};
thanks for any comments
uma