Skip to content

jextract/jni: Actor properties with synchronous access are imported as async #942

Open

Description

@teamhimeh

Problem

JNI extraction currently treats actor property accessors as implicitly async even when the property is explicitly nonisolated. It also misses the synchronous access path provided by an immutable actor property that witnesses a nonisolated protocol getter.

Example

public protocol Identified {
  var identifier: Int64 { get }
}

public actor Record: Identified {
  public let identifier: Int64
  public nonisolated var label: String { "record" }

  public init(identifier: Int64) {
    self.identifier = identifier
  }
}

Both getters can be exposed synchronously, so Java callers should be able to write:

long identifier = record.getIdentifier();
String label = record.getLabel();

Currently, both getters return CompletableFuture values.

For identifier, removing await from the generated thunk is not sufficient: outside the actor's defining module, direct access to the stored property remains isolated. Synchronous access is available through the protocol requirement, for example:

(record as any Identified).identifier

Reference workaround implementation: qoncept#4

Activity

  1. ktoso commented on Nov 4, 2026

    @ktoso
    Collaborator

    Good catch, thank you -- wouldn't you want to submit a fix rather than keep it only in the fork please @teamhimeh ?

  2. teamhimeh commented on Nov 4, 2026

    @teamhimeh
    Author

    @ktoso Thank you for watching this issue. We will submit the fix after our internal review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:jextractIssues related to jextract-swift

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions