Reflective constructor matching problem
Hello guys,
I have been working on dynamic construction of object by using reflection (Java 6 SE platform). I have noticed for example that there is a method:
Code:
Class.getConstructor(Calss[])
You pass the argument Class objects to this method and it gives you the corresponding constructor back. This works fine in most cases. But it has one problem. It dos not support autoboxing.
For example if the constructor of my class takes an parameter and and i ask the Class object for this class for the constructor like this: Code:
Class.getConstrucort(new Class[]{Integer.class})
i will get the NoSuchMethodException indicating that there is no matching constructor. If i match the constructor argument in the class definition exactly to the parameter type given to the method then i will have no problem.
Did anyone had any similar problems?
If any one has a solution or a workaround for this, i would need an advice.
Cheers