ich eine Klasse, die wie folgt aussieht:Java Generics und Reflexion!
public class UploadBean {
protected UploadBean(Map<String,?> map){
//do nothing.
}
}
Reflexion zu verwenden und ein Objekt erstellen, indem Sie den entsprechenden Konstruktor aufgerufen wird, schrieb ich Code wie folgt:
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);
Dieser Code zur Laufzeit nicht mit "Keine solche Methode Ausnahme". Nun, wie stelle ich den Param-Typ richtig ?! so dass das generische map-Argument im Konstruktor identifiziert wird?
WHat ist "Format"? –
Format ist eine Implementierung von dieser: öffentliche Schnittstelle FormatFactory { \t öffentliche Karte getFormat(); \t öffentliche Klasse erweitert UploadBean> getMappingBean(); } –
Jay