lundi 19 janvier 2015

Java, invoking constructor by reflection

How many times is slover to invoke constructor by reflection eg.:



Class c = map.get("somestr");
Constructor t = c.getDeclaredConstructor(int.class,MyClass.class);
MyObject o = (MyObject)t.invoke(<params>);
or
Constructor t = map.get("somestr");
MyObject o = (MyObject)t.invoke(<params>);


than using the keyword new?


Assuming the class will be cached.






Aucun commentaire:

Enregistrer un commentaire