Skip to content

Add tests and enhancements for CIR and injection mechanics#1

Merged
Splatcrafter merged 14 commits into
developfrom
feature/first-removal-of-mvp-states
Sep 15, 2025
Merged

Add tests and enhancements for CIR and injection mechanics#1
Splatcrafter merged 14 commits into
developfrom
feature/first-removal-of-mvp-states

Conversation

@Splatcrafter

@Splatcrafter Splatcrafter commented Sep 15, 2025

Copy link
Copy Markdown
Member

Overview of Changes

This pull request introduces comprehensive end-to-end tests, refactors, and enhances framework capabilities for CallbackInfoReturnable (CIR) and injection mechanics. Key changes include:

Testing

  • Added extensive tests for CI/CIR behaviors including head injections, tail overrides, return value manipulation, and method cancellation.
  • Introduced negative tests for invalid CI/CIR usage, especially for invalid descriptor applications.
  • Validated mixin configurations for robustness and correctness.

Refactors

  • Refactored InjectHeadAdapter and InjectTailAdapter to improve callback handling and parameter validation.
  • Centralized descriptor validation and operand logic into HookShape utility for improved maintainability.

Features

  • Introduced a @Shadow annotation for field/method remapping.
  • Enhanced flexibility of hook descriptor shapes, supporting and handling constructors, owners, and parameters.
  • Added cancellation support via a cancellable property in the @Inject annotation and a CancellationException API.

Remaining Tasks

  • Review and validate test coverage for advanced injection scenarios.
  • Confirm documentation updates align with new features.
  • Resolve any remaining discrepancies in weaving and runtime behavior.

Related Issues/Discussions

No issues referenced.

Thank you for reviewing these changes. Please provide feedback or suggest improvements!

- Skip weaving for classes/methods with no injects or redirects.
- Handle write failures with optional safe mode fallback.
- Introduce `pathResolve` and `pathWeave` for detailed diagnostics.
- Skip abstract and native method transformations.
- Add `@SuppressWarnings` to avoid constant condition warnings.
…e hook parameter shapes:

- Add support for hook descriptor shapes: `()V`, `(OWNER;)V`, `(args)V`, `(OWNER;args)V`.
- Introduce type validation and operand marshaling logic for descriptor compatibility.
- Adjust weaving logic in `AsmHookResolver`, `InjectHeadAdapter`, and `InjectTailAdapter` to support enhanced validation and descriptor matching.
- Update `AsmWeaver` to pass owner, access, and descriptor into adapters.
- Standardize and improve documentation consistency across modules.
- Replace MVP-specific notes with general descriptions or forward-looking statements.
- Align terminology with current and planned feature design.
- Add thread-safety notes and clarify method behaviors where relevant.
… descriptor validation:

- Extend `InjectHeadAdapter` and `InjectTailAdapter` to support new hook shapes, including `CallbackInfo` support.
- Introduce `HookShape` utility for classifying and validating hook descriptors.
- Replace duplicated descriptor validation logic with reusable utility methods.
- Add `CallbackInfo` class to support cancellation mechanics in hook executions.
…`, and `CallbackInfoReturnable`:

- Add `Cancellable` interface to standardize runtime cancellation mechanics.
- Introduce `CancellationException` for non-cancellable operation handling.
- Implement `CallbackInfoReturnable` to support return value manipulation and cancellation.
- Introduce `cancellable` flag in `@Inject` to enable cancellation of target methods via `CallbackInfo` or `CallbackInfoReturnable`.
- Update `@Inject` documentation to reflect cancellation support.
…escriptor handling:

- Add `@Shadow` API for field and method remapping support.
- Extend `HookShape` utility to support `CallbackInfoReturnable`.
- Implement CIR-specific descriptor validation and argument handling.
- Add operand emission methods for CIR initialization, loading, and return manipulation.
- Add `CIR_INTERNAL` for handling `CallbackInfoReturnable`.
- Update hook shape matching to include CIR support.
- Implement descriptor validation logic for CIR usage.
- Introduce CIR initialization, operand marshalling, and return handling mechanics.
- Add `CIR_INTERNAL` for handling `CallbackInfoReturnable`.
- Update hook shape matching to include CIR support.
- Implement descriptor validation logic for CIR usage in tail injections.
- Introduce CIR initialization, operand marshalling, and return handling mechanics.
…r enhanced callback handling:

- Replace `MethodVisitor` with `InjectHeadAdapter`/`InjectTailAdapter` instances in `HookShape` methods.
- Add method name and cancellable flag parameters to CallbackInfo creation logic for improved debugging.
- Extend operand marshaling and return handling mechanics to support detailed CallbackInfo operations.
- Introduce specialized methods for handling primitive return types in `CallbackInfoReturnable`.
- Introduce test resources for validating CI/CIR usage, including head, tail, and cancellation scenarios.
- Add negative tests for invalid CI and CIR application (e.g., CI on non-void or CIR on void methods).
- Validate CIR behavior for return value manipulation and cancellation.
- Verify CI side effects and constructor injection support.
- Add comprehensive tests for CI and CIR behaviors, including head injections, return manipulation, and method cancellations.
- Validate constructor injection and scenarios with and without return value manipulation.
- Verify proper handling of mixin configurations for runtime behaviors and detailed assertions.
- Introduce tests for CI and CIR behaviors, including head injections, tail overrides, synchronized method handling, and return value manipulation.
- Add priority resolution tests for CIR tail injections.
- Validate mixin configurations and assertions for null and static behavior.
- Add negative test for invalid CI usage on static methods.
@Splatcrafter Splatcrafter self-assigned this Sep 15, 2025
@Splatcrafter Splatcrafter added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 15, 2025
@Splatcrafter Splatcrafter merged commit 1889480 into develop Sep 15, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant