Skip to content

Feat/generate method handles#354

Merged
twisti-dev merged 6 commits into
version/26.1from
feat/generate-method-handles
May 22, 2026
Merged

Feat/generate method handles#354
twisti-dev merged 6 commits into
version/26.1from
feat/generate-method-handles

Conversation

@twisti-dev
Copy link
Copy Markdown
Contributor

This pull request introduces a new reflection processing system into the surf-api-processor module, adds supporting utility methods, and updates dependencies to support these features. The reflection system includes a KSP symbol processor, exception handling, and a comprehensive model for representing reflected members and their arguments. Additionally, the build configuration is updated to include the necessary libraries, and the version is bumped to 3.13.0.

Reflection Processing System

  • Added a new KSP symbol processor for reflection (ReflectionSymbolProcessorProvider) and registered it as a service, enabling annotation processing for reflection-related features. [1] [2]
  • Introduced model classes for representing constant arguments, Java parameters, nullability, reflected members, and the overall reflection model, providing a structured way to handle reflection metadata. [1] [2] [3] [4] [5]
  • Added a custom exception class for the reflection processor to improve error reporting.

Utilities and Class Name Management

  • Extended ClassNames and introduced ShortClassNames to support both full and short class names for reflection-related annotations and arguments, and added utility functions for extracting these names. [1] [2]
  • Added utility extension functions to simplify extracting annotation arguments of various types (string, boolean, int, long, enum) from KSP annotations.

Build Configuration and Dependency Updates

  • Updated the project version to 3.13.0 in gradle.properties.
  • Added kotlin-compiler and javapoet to dependencies for code generation and processing support. [1] [2]

Cleanup and Preparation

  • Removed the hand-written NmsReflections.java class, likely in preparation for generating similar code via the new reflection processing system.
  • Cleaned up unused imports in the NMS command argument bridge implementation.

… reflection processing

- introduce JavaNullability enum to represent nullability states
- create ReflectionModel data class to encapsulate reflection data
- add JavaParameter data class for method parameter representation
- implement ConstantArgument sealed interface for constant values
- define ReflectedMember interface and its implementations for methods, constructors, fields, and var handles
- add ReflectionSymbolProcessorProvider for symbol processing integration
…tion handling

- replace V26_1Reflection references with V26_1NmsReflections in multiple files
- add new V26_1NmsReflections interface with reflection methods for entity flags and chat handling
- update glowing flag calculations to use new reflection methods
@twisti-dev twisti-dev self-assigned this May 22, 2026
Copilot AI review requested due to automatic review settings May 22, 2026 18:17
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 introduces a new compile-time “generated reflection” system (annotations + KSP processor + Java emitter) and migrates Paper NMS modules away from the previous proxy/reflection-remapper approach for a set of reflected members (fields/methods/VarHandle ops). It also updates build configuration and versions to support the new processor and code generation workflow.

Changes:

  • Added public reflection annotations + runtime accessor loader (@GenerateReflection, @Reflected*, generatedReflectionAccessor) and updated shared-public ABI dump.
  • Added a new KSP processor (ReflectionSymbolProcessorProvider / ReflectionSymbolProcessor) with a JavaPoet-based emitter to generate reflection-handle implementations.
  • Migrated v1_21_11 and v26_1 NMS reflection usage to new generated reflection interfaces; removed old proxy interfaces and handwritten NmsReflections.java; simplified command argument bridge logic.

Reviewed changes

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

Show a summary per file
File Description
surf-api-shared/surf-api-shared-public/src/main/kotlin/dev/slne/surf/api/shared/api/reflection/GeneratedReflectionAccessor.kt Adds runtime loader/cache for generated reflection impls
surf-api-shared/surf-api-shared-public/src/main/kotlin/dev/slne/surf/api/shared/api/reflection/GeneratedReflection.kt Adds public reflection annotations + KDoc
surf-api-shared/surf-api-shared-public/api/surf-api-shared-public.api Updates ABI dump for new public APIs
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v26-1/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v26_1/reflection/V26_1VanillaArgumentProviderProxy.kt Removes old proxy interface
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v26-1/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v26_1/reflection/V26_1VanillaArgumentProviderImplProxy.kt Removes old proxy interface
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v26-1/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v26_1/reflection/V26_1ServerStatsCounterProxy.kt Removes old remapper proxy
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v26-1/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v26_1/reflection/V26_1ServerConnectionListenerProxy.kt Removes old remapper proxy
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v26-1/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v26_1/reflection/V26_1Reflection.kt Disables old init path (now no-op)
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v26-1/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v26_1/reflection/V26_1NmsReflections.kt Introduces generated-reflection interface for v26_1
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v26-1/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v26_1/reflection/V26_1EntityProxy.kt Removes old remapper proxy
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v26-1/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v26_1/packet/listener/V26_1GlowingPacketListener.kt Switches to generated reflections
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v26-1/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v26_1/glow/V26_1SurfGlowingApiImpl.kt Switches to generated reflections
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v26-1/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v26_1/glow/block/BlockGlowingData.kt Switches to generated reflections
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v26-1/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v26_1/bridges/V26_1SurfPaperNmsStatsBridgeImpl.kt Switches to generated reflections
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v26-1/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v26_1/bridges/V26_1SurfPaperNmsPlayerBridgeImpl.kt Switches to generated reflections
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v26-1/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v26_1/bridges/V26_1SurfPaperNmsGlowingBridgeImpl.kt Switches to generated reflections
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v26-1/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v26_1/bridges/V26_1SurfPaperNmsCommonBridgeImpl.kt Switches to generated reflections
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v26-1/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v26_1/bridges/V26_1SurfPaperNmsCommandArgumentTypesBridgeImpl.kt Removes ByteBuddy wrapping/proxy path
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v26-1/src/main/java/dev/slne/surf/api/paper/server/nms/v26_1/reflection/NmsReflections.java Removes handwritten reflection handles
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v1-21-11/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v1_21_11/reflection/V1_21_11VanillaArgumentProviderProxy.kt Removes old proxy interface
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v1-21-11/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v1_21_11/reflection/V1_21_11VanillaArgumentProviderImplProxy.kt Removes old proxy interface
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v1-21-11/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v1_21_11/reflection/V1_21_11ServerStatsCounterProxy.kt Removes old remapper proxy
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v1-21-11/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v1_21_11/reflection/V1_21_11ServerConnectionListenerProxy.kt Removes old remapper proxy
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v1-21-11/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v1_21_11/reflection/V1_21_11Reflection.kt Reduces init to only ITEM proxy
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v1-21-11/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v1_21_11/reflection/V1_21_11NmsReflections.kt Introduces generated-reflection interface for v1_21_11
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v1-21-11/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v1_21_11/reflection/V1_21_11ItemProxy.kt Adds class-name suppression annotation
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v1-21-11/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v1_21_11/reflection/V1_21_11EntityProxy.kt Removes old remapper proxy
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v1-21-11/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v1_21_11/packet/listener/V1_21_11GlowingPacketListener.kt Switches to generated reflections
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v1-21-11/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v1_21_11/glow/V1_21_11SurfGlowingApiImpl.kt Switches to generated reflections
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v1-21-11/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v1_21_11/glow/block/BlockGlowingData.kt Switches to generated reflections
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v1-21-11/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v1_21_11/bridges/V1_21_11SurfPaperNmsStatsBridgeImpl.kt Switches to generated reflections
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v1-21-11/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v1_21_11/bridges/V1_21_11SurfPaperNmsPlayerBridgeImpl.kt Switches to generated reflections
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v1-21-11/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v1_21_11/bridges/V1_21_11SurfPaperNmsGlowingBridgeImpl.kt Switches to generated reflections
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v1-21-11/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v1_21_11/bridges/V1_21_11SurfPaperNmsCommonBridgeImpl.kt Switches to generated reflections
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v1-21-11/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v1_21_11/bridges/V1_21_11SurfPaperNmsCommandArgumentTypesBridgeImpl.kt Removes ByteBuddy wrapping/proxy path
surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v1-21-11/src/main/java/dev/slne/surf/api/paper/server/nms/v1_21_11/reflection/NmsReflections.java Removes handwritten reflection handles
surf-api-gradle-plugin/surf-api-processor/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider Registers new reflection processor provider
surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/api/processor/util/util.kt Adds short-name helper (shortNameOf)
surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/api/processor/util/AnnotationUtils.kt Adds typed argument extraction helpers
surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/api/processor/reflection/ReflectionSymbolProcessorProvider.kt Adds reflection KSP provider
surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/api/processor/reflection/ReflectionSymbolProcessor.kt Adds reflection KSP processor + model building
surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/api/processor/reflection/model/ReflectionModel.kt Adds reflection model container
surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/api/processor/reflection/model/ReflectedMember.kt Adds reflected-member sealed model
surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/api/processor/reflection/model/JavaParameter.kt Adds Java parameter model
surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/api/processor/reflection/model/JavaNullability.kt Adds nullability enum for generation
surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/api/processor/reflection/model/ConstantArgument.kt Adds constant-argument model + Java literal emission
surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/api/processor/reflection/exception/ReflectionProcessorException.kt Adds processor exception type
surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/api/processor/reflection/emitter/ReflectionJavaEmitter.kt Adds Java code emitter for generated impls
surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/api/processor/ClassNames.kt Adds reflection annotation class-name constants
surf-api-gradle-plugin/surf-api-processor/build.gradle.kts Adds javapoet + kotlin-compiler deps
gradle/libs.versions.toml Adds kotlin-compiler entry; formatting tweak
gradle.properties Bumps project version to 3.13.0

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d5c358196a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…ctionSymbolProcessor

- replace multiple filter and forEach calls with a single for loop and when expression
- improve readability and maintainability of constant argument processing logic
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

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

@twisti-dev twisti-dev merged commit f2e0a1c into version/26.1 May 22, 2026
11 checks passed
@twisti-dev twisti-dev deleted the feat/generate-method-handles branch May 22, 2026 19:22
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