Skip to content

Commit

Permalink
Ensure methods in anonymous classes are accessible
Browse files Browse the repository at this point in the history
  • Loading branch information
pshevche committed Apr 15, 2024
1 parent 6a927d9 commit 110ad97
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public Object invoke(Object proxy, Method method, Object[] args) {
try {
Method targetMethod = target.getClass().getMethod(method.getName(), convertTypes(method.getParameterTypes(), target.getClass().getClassLoader()));
Object[] targetArgs = toTargetArgs(args);

// we always invoke public methods, but we need to make it accessible when it is implemented in anonymous classes
targetMethod.setAccessible(true);

Object result = targetMethod.invoke(target, targetArgs);
if (result == null || isJdkType(result.getClass())) {
return result;
Expand Down

0 comments on commit 110ad97

Please sign in to comment.