I have an interface which is generic:
public interface DataTable < T > {
}
And I have a Factory class returning an instance of my class that implements DataTable<T>
public class DataTableFactory<T> {
public DataTable<T> getInstance() {
return dataTableImpl();
}
}
And another class named as list which has a method public void setDataTable(DataTable < T > dataTable)
Now i just want to invoke this method by using java reflection:
Helper helper = new Helper(operationsFile);
Class c = null;
c = Class.forName(helper.getClassName("list"));
Object t = c.newInstance();
Method methodSetDataTable = c.getDeclaredMethod("setDataTable", paramTypes);
In this example I couldn't find how to get paramTypes
.
在没有看到setDataTable
的方法声明的setDataTable
,我希望param类型只是DataTable.class
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.