Skip to content

[JExtract] Mark @Sendable closures as @ThreadSafe (#832) - #929

Open
amanmaurya92 wants to merge 1 commit into
swiftlang:mainfrom
amanmaurya92:feature/issue-832-sendable-closures
Open

amanmaurya92 wants to merge 1 commit into
swiftlang:mainfrom
amanmaurya92:feature/issue-832-sendable-closures

Conversation

@amanmaurya92

Copy link
Copy Markdown
Contributor

Resolves #832

Problem

When a Swift closure parameter was annotated with @Sendable, the generated Java functional interface did not preserve this thread-safety information.

Solution

  • Marked the generated Java closure interface with @ThreadSafe // Sendable (for both JNI and FFM).
  • Preserved @Sendable in Swift thunks and added : @unchecked Sendable to escaping closure @JavaInterface structs.
  • Excluded @Sendable closures from collapsing into standard JDK interfaces (Runnable, LongConsumer) so the annotation is kept.
  • Added AST parser tests, JNI/FFM generator tests, and real-JVM runtime tests.

Formatted using Gemini

@amanmaurya92
amanmaurya92 requested a review from ktoso as a code owner October 5, 2026 17:00
@amanmaurya92
amanmaurya92 force-pushed the feature/issue-832-sendable-closures branch from 7d9eeed to 59144f7 Compare October 5, 2026 18:27
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.

jextract: closures with @Sendable should keep this information in generated java "closure" type

1 participant