Revert from getParameterCount() to getParameterTypes().length to be Java 1.7 compatible.

This reverts commit bc27c7c464.

Closes #10840
This commit is contained in:
Alexander Schwartz 2022-03-21 15:34:11 +01:00 committed by Hynek Mlnařík
parent c71aa8b711
commit fb92b95c33
6 changed files with 10 additions and 10 deletions

View file

@ -163,7 +163,7 @@ public class JBossWebPrincipalFactory implements PrincipalFactory {
static Constructor findJBossGenericPrincipalConstructor() {
for (Constructor<?> c : JBossGenericPrincipal.class.getConstructors()) {
if (c.getParameterCount() == 9 &&
if (c.getParameterTypes().length == 9 &&
c.getParameterTypes()[0].equals(Realm.class) &&
c.getParameterTypes()[1].equals(String.class) &&
c.getParameterTypes()[3].equals(List.class) &&

View file

@ -163,9 +163,9 @@ public class Types {
if (method == intfMethod) return true;
if (!method.getName().equals(intfMethod.getName())) return false;
if (method.getParameterCount() != intfMethod.getParameterCount()) return false;
if (method.getParameterTypes().length != intfMethod.getParameterTypes().length) return false;
for (int i = 0; i < method.getParameterCount(); i++)
for (int i = 0; i < method.getParameterTypes().length; i++)
{
Class rootParam = method.getParameterTypes()[i];
Class intfParam = intfMethod.getParameterTypes()[i];

View file

@ -323,7 +323,7 @@ public class LDAPUtils {
@Override
public boolean methodMatches(Method m) {
if ((m.getName().startsWith("get") || m.getName().startsWith("is"))
&& m.getParameterCount() > 0) {
&& m.getParameterTypes().length > 0) {
return false;
}

View file

@ -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.getParameterCount() > 0) {
} else if (method.getParameterTypes().length > 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.getParameterCount() != 1) {
} else if (method.getParameterTypes().length != 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.getParameterCount() == 1) {
if (methodName.startsWith(SETTER_METHOD_PREFIX) && method.getParameterTypes().length == 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.getParameterCount() == 0) {
if (method.getParameterTypes().length == 0) {
if (methodName.startsWith(GETTER_METHOD_PREFIX)) {
if (Introspector.decapitalize(methodName.substring(GETTER_METHOD_PREFIX_LENGTH)).equals(name)) {
return method;

View file

@ -1973,7 +1973,7 @@ public class PermissionsTest extends AbstractKeycloakTest {
List<String> ignoreList = Arrays.asList(ignore);
for (Method m : rep.getClass().getDeclaredMethods()) {
if (m.getParameterCount() == 0 && m.getName().startsWith("get") && !ignoreList.contains(m.getName())) {
if (m.getParameters().length == 0 && m.getName().startsWith("get") && !ignoreList.contains(m.getName())) {
try {
Object o = m.invoke(rep);
assertNull("Expected " + m.getName() + " to be null", o);

View file

@ -276,7 +276,7 @@ public class MultiVersionClusterTest extends AbstractClusterTest {
if (Arrays.asList(classForName.getDeclaredConstructors()).stream()
.filter(c -> !c.isSynthetic())
.anyMatch(c -> c.getParameterCount() == 0 )) {
.anyMatch(c -> c.getParameterTypes().length == 0 )) {
newInstance = Reflections.newInstance(classForName);
} else {
Constructor<?> constructor = Arrays.asList(classForName.getDeclaredConstructors()).stream()