Fix raw Class types
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@829364 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6eab86bafd
commit
fdb8010676
|
@ -124,7 +124,7 @@ public class MethodUtils {
|
||||||
args = ArrayUtils.EMPTY_OBJECT_ARRAY;
|
args = ArrayUtils.EMPTY_OBJECT_ARRAY;
|
||||||
}
|
}
|
||||||
int arguments = args.length;
|
int arguments = args.length;
|
||||||
Class[] parameterTypes = new Class[arguments];
|
Class<?>[] parameterTypes = new Class[arguments];
|
||||||
for (int i = 0; i < arguments; i++) {
|
for (int i = 0; i < arguments; i++) {
|
||||||
parameterTypes[i] = args[i].getClass();
|
parameterTypes[i] = args[i].getClass();
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ public class MethodUtils {
|
||||||
* @throws IllegalAccessException if the requested method is not accessible via reflection
|
* @throws IllegalAccessException if the requested method is not accessible via reflection
|
||||||
*/
|
*/
|
||||||
public static Object invokeMethod(Object object, String methodName,
|
public static Object invokeMethod(Object object, String methodName,
|
||||||
Object[] args, Class[] parameterTypes)
|
Object[] args, Class<?>[] parameterTypes)
|
||||||
throws NoSuchMethodException, IllegalAccessException,
|
throws NoSuchMethodException, IllegalAccessException,
|
||||||
InvocationTargetException {
|
InvocationTargetException {
|
||||||
if (parameterTypes == null) {
|
if (parameterTypes == null) {
|
||||||
|
@ -220,7 +220,7 @@ public class MethodUtils {
|
||||||
args = ArrayUtils.EMPTY_OBJECT_ARRAY;
|
args = ArrayUtils.EMPTY_OBJECT_ARRAY;
|
||||||
}
|
}
|
||||||
int arguments = args.length;
|
int arguments = args.length;
|
||||||
Class[] parameterTypes = new Class[arguments];
|
Class<?>[] parameterTypes = new Class[arguments];
|
||||||
for (int i = 0; i < arguments; i++) {
|
for (int i = 0; i < arguments; i++) {
|
||||||
parameterTypes[i] = args[i].getClass();
|
parameterTypes[i] = args[i].getClass();
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ public class MethodUtils {
|
||||||
* via reflection
|
* via reflection
|
||||||
*/
|
*/
|
||||||
public static Object invokeExactMethod(Object object, String methodName,
|
public static Object invokeExactMethod(Object object, String methodName,
|
||||||
Object[] args, Class[] parameterTypes)
|
Object[] args, Class<?>[] parameterTypes)
|
||||||
throws NoSuchMethodException, IllegalAccessException,
|
throws NoSuchMethodException, IllegalAccessException,
|
||||||
InvocationTargetException {
|
InvocationTargetException {
|
||||||
if (args == null) {
|
if (args == null) {
|
||||||
|
@ -285,8 +285,8 @@ public class MethodUtils {
|
||||||
* @throws IllegalAccessException if the requested method is not accessible
|
* @throws IllegalAccessException if the requested method is not accessible
|
||||||
* via reflection
|
* via reflection
|
||||||
*/
|
*/
|
||||||
public static Object invokeExactStaticMethod(Class cls, String methodName,
|
public static Object invokeExactStaticMethod(Class<?> cls, String methodName,
|
||||||
Object[] args, Class[] parameterTypes)
|
Object[] args, Class<?>[] parameterTypes)
|
||||||
throws NoSuchMethodException, IllegalAccessException,
|
throws NoSuchMethodException, IllegalAccessException,
|
||||||
InvocationTargetException {
|
InvocationTargetException {
|
||||||
if (args == null) {
|
if (args == null) {
|
||||||
|
@ -327,7 +327,7 @@ public class MethodUtils {
|
||||||
* @throws IllegalAccessException if the requested method is not accessible
|
* @throws IllegalAccessException if the requested method is not accessible
|
||||||
* via reflection
|
* via reflection
|
||||||
*/
|
*/
|
||||||
public static Object invokeStaticMethod(Class cls, String methodName,
|
public static Object invokeStaticMethod(Class<?> cls, String methodName,
|
||||||
Object arg) throws NoSuchMethodException, IllegalAccessException,
|
Object arg) throws NoSuchMethodException, IllegalAccessException,
|
||||||
InvocationTargetException {
|
InvocationTargetException {
|
||||||
return invokeStaticMethod(cls, methodName, new Object[] { arg });
|
return invokeStaticMethod(cls, methodName, new Object[] { arg });
|
||||||
|
@ -357,14 +357,14 @@ public class MethodUtils {
|
||||||
* @throws IllegalAccessException if the requested method is not accessible
|
* @throws IllegalAccessException if the requested method is not accessible
|
||||||
* via reflection
|
* via reflection
|
||||||
*/
|
*/
|
||||||
public static Object invokeStaticMethod(Class cls, String methodName,
|
public static Object invokeStaticMethod(Class<?> cls, String methodName,
|
||||||
Object[] args) throws NoSuchMethodException,
|
Object[] args) throws NoSuchMethodException,
|
||||||
IllegalAccessException, InvocationTargetException {
|
IllegalAccessException, InvocationTargetException {
|
||||||
if (args == null) {
|
if (args == null) {
|
||||||
args = ArrayUtils.EMPTY_OBJECT_ARRAY;
|
args = ArrayUtils.EMPTY_OBJECT_ARRAY;
|
||||||
}
|
}
|
||||||
int arguments = args.length;
|
int arguments = args.length;
|
||||||
Class[] parameterTypes = new Class[arguments];
|
Class<?>[] parameterTypes = new Class[arguments];
|
||||||
for (int i = 0; i < arguments; i++) {
|
for (int i = 0; i < arguments; i++) {
|
||||||
parameterTypes[i] = args[i].getClass();
|
parameterTypes[i] = args[i].getClass();
|
||||||
}
|
}
|
||||||
|
@ -393,8 +393,8 @@ public class MethodUtils {
|
||||||
* @throws IllegalAccessException if the requested method is not accessible
|
* @throws IllegalAccessException if the requested method is not accessible
|
||||||
* via reflection
|
* via reflection
|
||||||
*/
|
*/
|
||||||
public static Object invokeStaticMethod(Class cls, String methodName,
|
public static Object invokeStaticMethod(Class<?> cls, String methodName,
|
||||||
Object[] args, Class[] parameterTypes)
|
Object[] args, Class<?>[] parameterTypes)
|
||||||
throws NoSuchMethodException, IllegalAccessException,
|
throws NoSuchMethodException, IllegalAccessException,
|
||||||
InvocationTargetException {
|
InvocationTargetException {
|
||||||
if (parameterTypes == null) {
|
if (parameterTypes == null) {
|
||||||
|
@ -431,7 +431,7 @@ public class MethodUtils {
|
||||||
* @throws IllegalAccessException if the requested method is not accessible
|
* @throws IllegalAccessException if the requested method is not accessible
|
||||||
* via reflection
|
* via reflection
|
||||||
*/
|
*/
|
||||||
public static Object invokeExactStaticMethod(Class cls, String methodName,
|
public static Object invokeExactStaticMethod(Class<?> cls, String methodName,
|
||||||
Object arg) throws NoSuchMethodException, IllegalAccessException,
|
Object arg) throws NoSuchMethodException, IllegalAccessException,
|
||||||
InvocationTargetException {
|
InvocationTargetException {
|
||||||
return invokeExactStaticMethod(cls, methodName, new Object[] { arg });
|
return invokeExactStaticMethod(cls, methodName, new Object[] { arg });
|
||||||
|
@ -455,14 +455,14 @@ public class MethodUtils {
|
||||||
* @throws IllegalAccessException if the requested method is not accessible
|
* @throws IllegalAccessException if the requested method is not accessible
|
||||||
* via reflection
|
* via reflection
|
||||||
*/
|
*/
|
||||||
public static Object invokeExactStaticMethod(Class cls, String methodName,
|
public static Object invokeExactStaticMethod(Class<?> cls, String methodName,
|
||||||
Object[] args) throws NoSuchMethodException,
|
Object[] args) throws NoSuchMethodException,
|
||||||
IllegalAccessException, InvocationTargetException {
|
IllegalAccessException, InvocationTargetException {
|
||||||
if (args == null) {
|
if (args == null) {
|
||||||
args = ArrayUtils.EMPTY_OBJECT_ARRAY;
|
args = ArrayUtils.EMPTY_OBJECT_ARRAY;
|
||||||
}
|
}
|
||||||
int arguments = args.length;
|
int arguments = args.length;
|
||||||
Class[] parameterTypes = new Class[arguments];
|
Class<?>[] parameterTypes = new Class[arguments];
|
||||||
for (int i = 0; i < arguments; i++) {
|
for (int i = 0; i < arguments; i++) {
|
||||||
parameterTypes[i] = args[i].getClass();
|
parameterTypes[i] = args[i].getClass();
|
||||||
}
|
}
|
||||||
|
@ -481,10 +481,10 @@ public class MethodUtils {
|
||||||
* @param parameterType taking this type of parameter
|
* @param parameterType taking this type of parameter
|
||||||
* @return The accessible method
|
* @return The accessible method
|
||||||
*/
|
*/
|
||||||
public static Method getAccessibleMethod(Class cls, String methodName,
|
public static Method getAccessibleMethod(Class<?> cls, String methodName,
|
||||||
Class parameterType) {
|
Class<?> parameterType) {
|
||||||
return getAccessibleMethod(cls, methodName,
|
return getAccessibleMethod(cls, methodName,
|
||||||
new Class[] { parameterType });
|
new Class<?>[] { parameterType });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -499,8 +499,8 @@ public class MethodUtils {
|
||||||
* @param parameterTypes with these parameters types
|
* @param parameterTypes with these parameters types
|
||||||
* @return The accessible method
|
* @return The accessible method
|
||||||
*/
|
*/
|
||||||
public static Method getAccessibleMethod(Class cls, String methodName,
|
public static Method getAccessibleMethod(Class<?> cls, String methodName,
|
||||||
Class[] parameterTypes) {
|
Class<?>[] parameterTypes) {
|
||||||
try {
|
try {
|
||||||
return getAccessibleMethod(cls.getMethod(methodName,
|
return getAccessibleMethod(cls.getMethod(methodName,
|
||||||
parameterTypes));
|
parameterTypes));
|
||||||
|
@ -522,12 +522,12 @@ public class MethodUtils {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// If the declaring class is public, we are done
|
// If the declaring class is public, we are done
|
||||||
Class cls = method.getDeclaringClass();
|
Class<?> cls = method.getDeclaringClass();
|
||||||
if (Modifier.isPublic(cls.getModifiers())) {
|
if (Modifier.isPublic(cls.getModifiers())) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
String methodName = method.getName();
|
String methodName = method.getName();
|
||||||
Class[] parameterTypes = method.getParameterTypes();
|
Class<?>[] parameterTypes = method.getParameterTypes();
|
||||||
|
|
||||||
// Check the implemented interfaces and subinterfaces
|
// Check the implemented interfaces and subinterfaces
|
||||||
method = getAccessibleMethodFromInterfaceNest(cls, methodName,
|
method = getAccessibleMethodFromInterfaceNest(cls, methodName,
|
||||||
|
@ -550,9 +550,9 @@ public class MethodUtils {
|
||||||
* @param methodName Method name of the method we wish to call
|
* @param methodName Method name of the method we wish to call
|
||||||
* @param parameterTypes The parameter type signatures
|
* @param parameterTypes The parameter type signatures
|
||||||
*/
|
*/
|
||||||
private static Method getAccessibleMethodFromSuperclass(Class cls,
|
private static Method getAccessibleMethodFromSuperclass(Class<?> cls,
|
||||||
String methodName, Class[] parameterTypes) {
|
String methodName, Class<?>[] parameterTypes) {
|
||||||
Class parentClass = cls.getSuperclass();
|
Class<?> parentClass = cls.getSuperclass();
|
||||||
while (parentClass != null) {
|
while (parentClass != null) {
|
||||||
if (Modifier.isPublic(parentClass.getModifiers())) {
|
if (Modifier.isPublic(parentClass.getModifiers())) {
|
||||||
try {
|
try {
|
||||||
|
@ -580,15 +580,15 @@ public class MethodUtils {
|
||||||
* @param methodName Method name of the method we wish to call
|
* @param methodName Method name of the method we wish to call
|
||||||
* @param parameterTypes The parameter type signatures
|
* @param parameterTypes The parameter type signatures
|
||||||
*/
|
*/
|
||||||
private static Method getAccessibleMethodFromInterfaceNest(Class cls,
|
private static Method getAccessibleMethodFromInterfaceNest(Class<?> cls,
|
||||||
String methodName, Class[] parameterTypes) {
|
String methodName, Class<?>[] parameterTypes) {
|
||||||
Method method = null;
|
Method method = null;
|
||||||
|
|
||||||
// Search up the superclass chain
|
// Search up the superclass chain
|
||||||
for (; cls != null; cls = cls.getSuperclass()) {
|
for (; cls != null; cls = cls.getSuperclass()) {
|
||||||
|
|
||||||
// Check the implemented interfaces of the parent class
|
// Check the implemented interfaces of the parent class
|
||||||
Class[] interfaces = cls.getInterfaces();
|
Class<?>[] interfaces = cls.getInterfaces();
|
||||||
for (int i = 0; i < interfaces.length; i++) {
|
for (int i = 0; i < interfaces.length; i++) {
|
||||||
// Is this interface public?
|
// Is this interface public?
|
||||||
if (!Modifier.isPublic(interfaces[i].getModifiers())) {
|
if (!Modifier.isPublic(interfaces[i].getModifiers())) {
|
||||||
|
@ -638,8 +638,8 @@ public class MethodUtils {
|
||||||
* @param parameterTypes find method with most compatible parameters
|
* @param parameterTypes find method with most compatible parameters
|
||||||
* @return The accessible method
|
* @return The accessible method
|
||||||
*/
|
*/
|
||||||
public static Method getMatchingAccessibleMethod(Class cls,
|
public static Method getMatchingAccessibleMethod(Class<?> cls,
|
||||||
String methodName, Class[] parameterTypes) {
|
String methodName, Class<?>[] parameterTypes) {
|
||||||
try {
|
try {
|
||||||
Method method = cls.getMethod(methodName, parameterTypes);
|
Method method = cls.getMethod(methodName, parameterTypes);
|
||||||
MemberUtils.setAccessibleWorkaround(method);
|
MemberUtils.setAccessibleWorkaround(method);
|
||||||
|
|
Loading…
Reference in New Issue