馃挜 Support Kotlin 2.4 async method references - #3111
Quinn-With-Two-Ns wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 1d2b815. Configure here.
1d2b815 to
b29eb8a
Compare
maciejdudko
left a comment
There was a problem hiding this comment.
The code looks good, but we should do better job documenting what we're fixing and why.
| To disable unwrapping Kotlin static adapters for method references passed to `Async`, set the | ||
| `temporal.kotlin.disableStaticAdapterUnwrapping` JVM system property. Its value does not matter; | ||
| for example, `-Dtemporal.kotlin.disableStaticAdapterUnwrapping` disables this fallback. This can | ||
| cause `Async` to stop recognizing method references compiled as static adapters. | ||
|
|
There was a problem hiding this comment.
Expand on why the option exists (incompatibility between Kotlin 2.2 and 2.4 causing NDE when using older SDK <=1.40).
There was a problem hiding this comment.
Update both these let me know what you think
| ### Added | ||
| - Kotlin `Async` static adapter unwrapping can be disabled with the | ||
| `temporal.kotlin.disableStaticAdapterUnwrapping` JVM system property. |
There was a problem hiding this comment.
Replace with a note in Fixed section saying it fixes NDE when upgrading from Kotlin 2.2 to 2.4, and that already started 2.4 workflows can use temporal.kotlin.disableStaticAdapterUnwrapping.

What was changed
Support Kotlin 2.4 async method references.
Why?
Kotlin 2.4 changed how it generated async method references breaking some optimization in the SDK and causing NDE
Checklist
Closes
Async.function/Async.procedurewith a Kotlin method reference spawns a WorkflowThread per call instead of inlining, as it does the Java equivalent聽#2981How was this tested:
Note
Medium Risk
Changes workflow async invocation and replay determinism for Kotlin method references; incorrect unwrapping could affect command ordering, though behavior is gated and documented via a system property.
Overview
Kotlin 2.4 compiles
Async.function/Async.proceduremethod references as serialized lambdas with static adapters that lack Kotlin metadata, so the SDK no longer treated them as inline stub calls and replay could hitNonDeterministicExceptionafter upgrading from Kotlin 2.2.The PR extends
KotlinDetectorandKotlinMethodReferenceDisassemblyService(Strategy 3) to recognize those adapters, unwrap the real stub target, and route them through the existing Kotlin async path inMethodReferenceDisassembler. A JVM flagtemporal.kotlin.disableStaticAdapterUnwrappingpreserves pre-fix replay behavior for workflows already started on Kotlin 2.4 with older SDKs. Edge CI is updated to compiletemporal-kotlinwith Kotlin 2.4.20, andKotlinAsyncMarkerTestcovers marked-stub method references vs capturing lambdas.Reviewed by Cursor Bugbot for commit a0d0314. Bugbot is set up for automated code reviews on this repo. Configure here.