diff options
| author | Kostya <mail@sartin.in> | 2026-07-22 21:39:03 +0000 |
|---|---|---|
| committer | Kostya <mail@sartin.in> | 2026-07-22 21:39:03 +0000 |
| commit | c1ad41584e68bcc1f3d5c48fd947e12dfcf20166 (patch) | |
| tree | 98a446c6ff442e68981a2729053346c29463862d /ex1 | |
| parent | ca78853ed74c3485b734ff28148711ad597bee2e (diff) | |
| download | java-course-c1ad41584e68bcc1f3d5c48fd947e12dfcf20166.tar.gz java-course-c1ad41584e68bcc1f3d5c48fd947e12dfcf20166.tar.xz java-course-c1ad41584e68bcc1f3d5c48fd947e12dfcf20166.zip | |
find method invocation
Diffstat (limited to 'ex1')
| -rw-r--r-- | ex1/src/main/java/reflection/api/ReflectionInvestigator.java | 6 | ||||
| -rw-r--r-- | ex1/target/classes/reflection/api/ReflectionInvestigator.class | bin | 6827 -> 6814 bytes |
2 files changed, 4 insertions, 2 deletions
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 { | |||
| 74 | 74 | ||
| 75 | @Override | 75 | @Override |
| 76 | public Set<String> getNamesOfAllFieldsIncludingInheritanceChain() { | 76 | public Set<String> getNamesOfAllFieldsIncludingInheritanceChain() { |
| 77 | return Stream.of(classInfo.getFields()).map(f -> f.getName()).collect(Collectors.toSet()); | 77 | return Stream.of(classInfo.getDeclaredFields()) |
| 78 | .map(f -> f.getName()) | ||
| 79 | .collect(Collectors.toSet()); | ||
| 78 | } | 80 | } |
| 79 | 81 | ||
| 80 | @Override | 82 | @Override |
| @@ -107,7 +109,7 @@ public class ReflectionInvestigator implements Investigator { | |||
| 107 | @Override | 109 | @Override |
| 108 | public Object elevateMethodAndInvoke(String name, Class<?>[] parametersTypes, Object... args) { | 110 | public Object elevateMethodAndInvoke(String name, Class<?>[] parametersTypes, Object... args) { |
| 109 | try { | 111 | try { |
| 110 | var method = classInfo.getMethod(name); | 112 | var method = classInfo.getMethod(name, parametersTypes); |
| 111 | method.setAccessible(true); | 113 | method.setAccessible(true); |
| 112 | return method.invoke(subjectInstance, args); | 114 | return method.invoke(subjectInstance, args); |
| 113 | } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { | 115 | } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { |
diff --git a/ex1/target/classes/reflection/api/ReflectionInvestigator.class b/ex1/target/classes/reflection/api/ReflectionInvestigator.class index 8becea9..f5127db 100644 --- a/ex1/target/classes/reflection/api/ReflectionInvestigator.class +++ b/ex1/target/classes/reflection/api/ReflectionInvestigator.class | |||
| Binary files differ | |||