I have a class that looks like this:
public class UploadBean {
protected UploadBean(Map<String,?> map){
//do nothing.
}
}
To use reflection and create a object by invoking the corresponding constructor, I wrote code as follows:
Class<?> parTypes[] = new Class<?>[1];
parTypes[0] = Map.class;
Constructor ct = format.getMappingBean().getConstructor(parTypes);
Object[] argList = new Object[1];
argList[0] = map;
Object retObj = ct.newInstance(argList);
This code fails at runtime with "No Such Method Exception". Now, how do I set the param type correctly?! such that the generic map argument in the constructor is identified?