mercredi 5 août 2015

Hi dear folks, Can somebody assist me to solve this issue?

I'm using java.reflection in my code. Also, I could see couple of warning notification as below:

The argument of type null should explicitly be cast to Class[] for the invocation of the varargs method getDeclaredMethod(String, Class...) from type Class. It could alternatively be cast to Class for a varargs invocation

Can somebody tell me the reason for this warning and how can i resolve it?

Sample code:

Class<?> c = Class.forName("complete.package.name.RegressionBuild");
RegressionBuild regression = (RegressionBuild) c.newInstance();
String methodName="debitCardDetails";
Method runtimeMethod = RegressionBuild.class.getDeclaredMethod(methodName, null);

Also the following line throws this warning message:

Multiple markers at this line The value of the local variable exeMethod is not used The argument of type null should explicitly be cast to Object[] for the invocation of the varargs method invoke(Object, Object...) from type Method. It could alternatively be cast to Object for a varargs invocation

code: String exeMethod = (String) runtimeMethod.invoke(regression, null);

However, It returns proper method, also printed null value in o/p console.

Can somebody assist me to solve this issue.

Thanks in advance sasi

Aucun commentaire:

Enregistrer un commentaire