我正在尝试通过 Java 反射调用一个方法,该方法没有任何参数:
Method getSelectedCriteriaMethod = multipleSorting.getClass().getDeclaredMethod("getSelectedCriteria", null);
EstimateSortField selectedCriteria = (EstimateSortField)getSelectedCriteriaMethod.invoke(multipleSorting, null);
这是有效的,但我收到编译器警告:
warning: non-varargs call of varargs method with inexact argument type for last parameter;
cast to java.lang.Class<?> for a varargs call
non-varargs call of varargs method with inexact argument type for last parameter;
cast to java.lang.Object for a varargs call
调用没有任何参数的方法的正确方法是什么?