SIGN IN SIGN UP

Refactor invokeSpecialMethod for reflection parity (#568)

We overhaul the `invokeSpecialMethod` backend to make it robust against JNI aborts and closer to standard Java reflection behavior, while maintaining reasonable performance.

Key improvements:
- Fix illegal `jclass{nullptr}` usage during return value boxing by globally caching primitive wrapper classes (`Integer`, `Double`, etc.).
- Eliminate heap allocations for argument mapping by replacing `std::vector` with stack-allocated memory via `alloca`.
- Prevent JNI type confusion crashes by introducing strict type validation (`IsInstanceOf`) before unboxing arguments.
- Safely catch native exceptions from the target method and wrap them in `InvocationTargetException`, mirroring `java.lang.reflect.Method.invoke`.
- Gracefully handle `null` receivers and zero-length argument arrays.
J
JingMatrix committed
8db19217d30062d39e6af29a62796a5d4c529680
Parent: fe8e069
Committed by GitHub <noreply@github.com> on 3/14/2026, 10:59:32 PM