Skip to content

Update version and enhance hidden class instantiation#273

Merged
twisti-dev merged 2 commits intoversion/1.21.11from
fix/package-private-template-access
Mar 31, 2026
Merged

Update version and enhance hidden class instantiation#273
twisti-dev merged 2 commits intoversion/1.21.11from
fix/package-private-template-access

Conversation

@twisti-dev
Copy link
Copy Markdown
Contributor

This pull request includes a version bump and a bug fix for hidden class instantiation in the core API. The most significant change addresses how hidden classes are instantiated, improving reliability and error handling.

Core API improvements

  • Updated the instantiation logic in HiddenInvokerUtil.java to use a MethodHandle for calling the constructor of hidden classes, and added improved error handling by catching Throwable and rethrowing as a ReflectiveOperationException for better diagnostics.

Versioning

  • Bumped the project version in gradle.properties from 1.21.11-2.73.0 to 1.21.11-2.73.1 to reflect the bug fix.

@twisti-dev twisti-dev self-assigned this Mar 31, 2026
Copilot AI review requested due to automatic review settings March 31, 2026 13:03
@twisti-dev twisti-dev merged commit 3b5da5d into version/1.21.11 Mar 31, 2026
4 checks passed
@twisti-dev twisti-dev deleted the fix/package-private-template-access branch March 31, 2026 13:04
Copy link
Copy Markdown
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

This PR bumps the project version and updates hidden-class invoker instantiation to use a MethodHandle constructor invocation, aiming to improve reliability and diagnostics when creating hidden invoker instances.

Changes:

  • Switch hidden class instantiation from reflection (getDeclaredConstructor().newInstance()) to Lookup.findConstructor(...).invoke().
  • Add error wrapping during hidden class instantiation by converting thrown failures into ReflectiveOperationException.
  • Bump version from 1.21.11-2.73.0 to 1.21.11-2.73.1.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
surf-api-core/surf-api-core-api/src/main/java/dev/slne/surf/surfapi/core/api/invoker/HiddenInvokerUtil.java Updates hidden-class instantiation approach and adjusts related JavaDoc.
gradle.properties Increments project version for the bug fix release.


try {
return invokerInterface.cast(constructor.invoke());
} catch (Throwable e) {
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

The new catch (Throwable e) wraps all Errors (e.g., OutOfMemoryError, StackOverflowError) into a ReflectiveOperationException, which can mask fatal JVM conditions and change failure semantics. Consider rethrowing Error (or at least VirtualMachineError/ThreadDeath/LinkageError) and only wrapping non-fatal throwables from MethodHandle.invoke() into ReflectiveOperationException.

Suggested change
} catch (Throwable e) {
} catch (Throwable e) {
if (e instanceof Error) {
throw (Error) e;
}

Copilot uses AI. Check for mistakes.
* @param methodType the expected {@link MethodType} for non-suspend handler methods.
* @return an {@link InvokerClassData} instance containing the resolved handler method
* information, along with metadata on whether it's a suspend function.
* information, along with metadata on whether it's a suspend function.
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

JavaDoc formatting regression: the continuation line after @return lost indentation/alignment (* information, ...). This reads like a paragraph break and is inconsistent with the surrounding JavaDoc style; re-indent to keep the wrapped @return description aligned.

Suggested change
* information, along with metadata on whether it's a suspend function.
* information, along with metadata on whether it's a suspend function.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants