fix problem with multiple method overrides in generic types.
This commit is contained in:
parent
239e921e6f
commit
b7333c2e5e
@ -12,11 +12,12 @@ public record AppliedCheck(InteractionCheck<?> check, Annotation annotation) {
|
|||||||
public boolean pre(Object context) {
|
public boolean pre(Object context) {
|
||||||
Method[] methods = Arrays.stream(check.getClass().getMethods())
|
Method[] methods = Arrays.stream(check.getClass().getMethods())
|
||||||
.filter(x -> x.getName().equals("preExec"))
|
.filter(x -> x.getName().equals("preExec"))
|
||||||
|
.filter(x -> !x.isBridge())
|
||||||
.toArray(s -> new Method[s]);
|
.toArray(s -> new Method[s]);
|
||||||
Method method = ReflectionUtil.getMostSpecificMethod(methods, context.getClass());
|
Method method = ReflectionUtil.getMostSpecificMethod(methods, context.getClass(), annotation.getClass());
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
try {
|
try {
|
||||||
return (boolean) method.invoke(check, annotation);
|
return (boolean) method.invoke(check, context, annotation);
|
||||||
} catch (IllegalAccessException | InvocationTargetException | SecurityException e) {
|
} catch (IllegalAccessException | InvocationTargetException | SecurityException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
@ -26,11 +27,12 @@ public record AppliedCheck(InteractionCheck<?> check, Annotation annotation) {
|
|||||||
public boolean post(Object context) {
|
public boolean post(Object context) {
|
||||||
Method[] methods = Arrays.stream(check.getClass().getMethods())
|
Method[] methods = Arrays.stream(check.getClass().getMethods())
|
||||||
.filter(x -> x.getName().equals("postExec"))
|
.filter(x -> x.getName().equals("postExec"))
|
||||||
|
.filter(x -> !x.isBridge())
|
||||||
.toArray(s -> new Method[s]);
|
.toArray(s -> new Method[s]);
|
||||||
Method method = ReflectionUtil.getMostSpecificMethod(methods, context.getClass());
|
Method method = ReflectionUtil.getMostSpecificMethod(methods, context.getClass(), annotation.getClass());
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
try {
|
try {
|
||||||
return (boolean) method.invoke(check, annotation);
|
return (boolean) method.invoke(check, context, annotation);
|
||||||
} catch (IllegalAccessException | InvocationTargetException | SecurityException e) {
|
} catch (IllegalAccessException | InvocationTargetException | SecurityException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user