Fix/invocation handler#199
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the project version and adjusts reflection-based method resolution in SurfInvocationHandlerJava to better support invoking non-public methods.
Changes:
- Bumped project version from
1.21.11-2.55.1to1.21.11-2.55.2. - Switched reflective lookup to
MethodUtils.getMatchingMethod(...)and explicitly marks the resolvedMethodas accessible.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| surf-api-core/surf-api-core-server/src/main/java/dev/slne/surf/surfapi/core/server/impl/reflection/SurfInvocationHandlerJava.java | Updates reflective method lookup and accessibility handling for method invocation. |
| gradle.properties | Version bump to 1.21.11-2.55.2. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| final Method method = MethodUtils.getMatchingMethod(clazz, methodName, paramTypes); | ||
| if (method != null) { | ||
| method.setAccessible(true); | ||
| } |
There was a problem hiding this comment.
method.setAccessible(true) can throw InaccessibleObjectException (JPMS/module access) or SecurityException. Right now that will escape as a runtime failure (and likely be wrapped by sneaky(...) later), which is harder to diagnose than a deliberate error. Consider using trySetAccessible() and, if it fails, throw an exception with a clear message about the target class/module not being opened (or fall back to a privateLookupIn(...).unreflect(...) approach).
This pull request includes a version bump and a minor but important fix to the reflection-based method resolution logic in
SurfInvocationHandlerJava. The main update ensures that methods found via reflection are made accessible, which improves compatibility with Java's access control, and updates the project version.Version update:
gradle.propertiesfrom1.21.11-2.55.1to1.21.11-2.55.2.Reflection handling improvements:
SurfInvocationHandlerJava.java, changed the reflective method lookup to useMethodUtils.getMatchingMethodinstead ofgetMatchingAccessibleMethod, and explicitly set found methods as accessible to ensure proper invocation of non-public methods.SurfInvocationHandlerJava.javato match the new usage of reflection utilities. [1] [2]