Replace occurrences of getParameterTypes().length and getParameters().length with getParameterCount()
This should reduce GC pressure. Closes #12644
This commit is contained in:
parent
ccc0449314
commit
4643fd09e3
5 changed files with 9 additions and 9 deletions
|
@ -163,9 +163,9 @@ public class Types {
|
|||
if (method == intfMethod) return true;
|
||||
|
||||
if (!method.getName().equals(intfMethod.getName())) return false;
|
||||
if (method.getParameterTypes().length != intfMethod.getParameterTypes().length) return false;
|
||||
if (method.getParameterCount() != intfMethod.getParameterCount()) return false;
|
||||
|
||||
for (int i = 0; i < method.getParameterTypes().length; i++)
|
||||
for (int i = 0; i < method.getParameterCount(); i++)
|
||||
{
|
||||
Class rootParam = method.getParameterTypes()[i];
|
||||
Class intfParam = intfMethod.getParameterTypes()[i];
|
||||
|
|
|
@ -323,7 +323,7 @@ public class LDAPUtils {
|
|||
@Override
|
||||
public boolean methodMatches(Method m) {
|
||||
if ((m.getName().startsWith("get") || m.getName().startsWith("is"))
|
||||
&& m.getParameterTypes().length > 0) {
|
||||
&& m.getParameterCount() > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class MethodPropertyImpl<V> implements MethodProperty<V> {
|
|||
if (method.getReturnType() == Void.TYPE) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid accessor method, must have return value if starts with 'get'. Method: " + method);
|
||||
} else if (method.getParameterTypes().length > 0) {
|
||||
} else if (method.getParameterCount() > 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid accessor method, must have zero arguments if starts with 'get'. Method: " + method);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ class MethodPropertyImpl<V> implements MethodProperty<V> {
|
|||
if (method.getReturnType() != Void.TYPE) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid accessor method, must not have return value if starts with 'set'. Method: " + method);
|
||||
} else if (method.getParameterTypes().length != 1) {
|
||||
} else if (method.getParameterCount() != 1) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid accessor method, must have one argument if starts with 'set'. Method: " + method);
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ class MethodPropertyImpl<V> implements MethodProperty<V> {
|
|||
Method[] methods = clazz.getMethods();
|
||||
for (Method method : methods) {
|
||||
String methodName = method.getName();
|
||||
if (methodName.startsWith(SETTER_METHOD_PREFIX) && method.getParameterTypes().length == 1) {
|
||||
if (methodName.startsWith(SETTER_METHOD_PREFIX) && method.getParameterCount() == 1) {
|
||||
if (Introspector.decapitalize(methodName.substring(SETTER_METHOD_PREFIX_LENGTH)).equals(name)) {
|
||||
return method;
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ class MethodPropertyImpl<V> implements MethodProperty<V> {
|
|||
private static Method getGetterMethod(Class<?> clazz, String name) {
|
||||
for (Method method : clazz.getDeclaredMethods()) {
|
||||
String methodName = method.getName();
|
||||
if (method.getParameterTypes().length == 0) {
|
||||
if (method.getParameterCount() == 0) {
|
||||
if (methodName.startsWith(GETTER_METHOD_PREFIX)) {
|
||||
if (Introspector.decapitalize(methodName.substring(GETTER_METHOD_PREFIX_LENGTH)).equals(name)) {
|
||||
return method;
|
||||
|
|
|
@ -1973,7 +1973,7 @@ public class PermissionsTest extends AbstractKeycloakTest {
|
|||
List<String> ignoreList = Arrays.asList(ignore);
|
||||
|
||||
for (Method m : rep.getClass().getDeclaredMethods()) {
|
||||
if (m.getParameters().length == 0 && m.getName().startsWith("get") && !ignoreList.contains(m.getName())) {
|
||||
if (m.getParameterCount() == 0 && m.getName().startsWith("get") && !ignoreList.contains(m.getName())) {
|
||||
try {
|
||||
Object o = m.invoke(rep);
|
||||
assertNull("Expected " + m.getName() + " to be null", o);
|
||||
|
|
|
@ -276,7 +276,7 @@ public class MultiVersionClusterTest extends AbstractClusterTest {
|
|||
|
||||
if (Arrays.asList(classForName.getDeclaredConstructors()).stream()
|
||||
.filter(c -> !c.isSynthetic())
|
||||
.anyMatch(c -> c.getParameterTypes().length == 0 )) {
|
||||
.anyMatch(c -> c.getParameterCount() == 0 )) {
|
||||
newInstance = Reflections.newInstance(classForName);
|
||||
} else {
|
||||
Constructor<?> constructor = Arrays.asList(classForName.getDeclaredConstructors()).stream()
|
||||
|
|
Loading…
Reference in a new issue