From c1ad41584e68bcc1f3d5c48fd947e12dfcf20166 Mon Sep 17 00:00:00 2001 From: Kostya Date: Wed, 22 Jul 2026 21:39:03 +0000 Subject: find method invocation --- ex1/src/main/java/reflection/api/ReflectionInvestigator.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ex1/src/main') diff --git a/ex1/src/main/java/reflection/api/ReflectionInvestigator.java b/ex1/src/main/java/reflection/api/ReflectionInvestigator.java index 054691b..f5d43f0 100644 --- a/ex1/src/main/java/reflection/api/ReflectionInvestigator.java +++ b/ex1/src/main/java/reflection/api/ReflectionInvestigator.java @@ -74,7 +74,9 @@ public class ReflectionInvestigator implements Investigator { @Override public Set getNamesOfAllFieldsIncludingInheritanceChain() { - return Stream.of(classInfo.getFields()).map(f -> f.getName()).collect(Collectors.toSet()); + return Stream.of(classInfo.getDeclaredFields()) + .map(f -> f.getName()) + .collect(Collectors.toSet()); } @Override @@ -107,7 +109,7 @@ public class ReflectionInvestigator implements Investigator { @Override public Object elevateMethodAndInvoke(String name, Class[] parametersTypes, Object... args) { try { - var method = classInfo.getMethod(name); + var method = classInfo.getMethod(name, parametersTypes); method.setAccessible(true); return method.invoke(subjectInstance, args); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { -- cgit v1.2.3