Add more empty array constants in ReflectionUtils
Add some additional empty array constants to `ReflectionUtils` to save us creating new arrays for zero length results. See gh-22567
This commit is contained in:
committed by
Juergen Hoeller
parent
e3a86be122
commit
19fb697d03
@@ -66,10 +66,14 @@ public abstract class ReflectionUtils {
|
|||||||
*/
|
*/
|
||||||
private static final String CGLIB_RENAMED_METHOD_PREFIX = "CGLIB$";
|
private static final String CGLIB_RENAMED_METHOD_PREFIX = "CGLIB$";
|
||||||
|
|
||||||
|
private static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];
|
||||||
|
|
||||||
private static final Method[] EMPTY_METHOD_ARRAY = new Method[0];
|
private static final Method[] EMPTY_METHOD_ARRAY = new Method[0];
|
||||||
|
|
||||||
private static final Field[] EMPTY_FIELD_ARRAY = new Field[0];
|
private static final Field[] EMPTY_FIELD_ARRAY = new Field[0];
|
||||||
|
|
||||||
|
private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache for {@link Class#getDeclaredMethods()} plus equivalent default methods
|
* Cache for {@link Class#getDeclaredMethods()} plus equivalent default methods
|
||||||
@@ -211,7 +215,7 @@ public abstract class ReflectionUtils {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Method findMethod(Class<?> clazz, String name) {
|
public static Method findMethod(Class<?> clazz, String name) {
|
||||||
return findMethod(clazz, name, new Class<?>[0]);
|
return findMethod(clazz, name, EMPTY_CLASS_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -255,7 +259,7 @@ public abstract class ReflectionUtils {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Object invokeMethod(Method method, @Nullable Object target) {
|
public static Object invokeMethod(Method method, @Nullable Object target) {
|
||||||
return invokeMethod(method, target, new Object[0]);
|
return invokeMethod(method, target, EMPTY_OBJECT_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user