Skip to content

Conversation

@twisti-dev
Copy link
Contributor

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:

  • Bumped the project version in gradle.properties from 1.21.11-2.55.1 to 1.21.11-2.55.2.

Reflection handling improvements:

  • In SurfInvocationHandlerJava.java, changed the reflective method lookup to use MethodUtils.getMatchingMethod instead of getMatchingAccessibleMethod, and explicitly set found methods as accessible to ensure proper invocation of non-public methods.
  • Adjusted imports in SurfInvocationHandlerJava.java to match the new usage of reflection utilities. [1] [2]

@twisti-dev twisti-dev self-assigned this Feb 2, 2026
@twisti-dev twisti-dev added the type: Fix PR that fixes an issue label Feb 2, 2026
Copilot AI review requested due to automatic review settings February 2, 2026 13:26
@twisti-dev twisti-dev added the java Pull requests that update java code label Feb 2, 2026
@twisti-dev twisti-dev merged commit 0da5b67 into version/1.21.11 Feb 2, 2026
12 checks passed
@twisti-dev twisti-dev deleted the fix/invocation-handler branch February 2, 2026 13:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.1 to 1.21.11-2.55.2.
  • Switched reflective lookup to MethodUtils.getMatchingMethod(...) and explicitly marks the resolved Method as 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.

Comment on lines +180 to +183
final Method method = MethodUtils.getMatchingMethod(clazz, methodName, paramTypes);
if (method != null) {
method.setAccessible(true);
}
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java Pull requests that update java code type: Fix PR that fixes an issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants