Repository navigation
JNI: support Foundation values in protocol callbacks - #5
Merged
Merged
Conversation
Bridge Data, Date, and URL with their generated wrappers and convert UUID through java.util.UUID. Register the UUID projection with runtime support so wrap-java preserves callback methods containing Java UUID signatures. Add regressions for Foundation and FoundationEssentials, Java callback round trips, and present or empty Optional Data and Date values.
This was referenced Oct 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
JNI protocol callbacks reject Foundation value types even though the Java-facing method signatures already support them. As a result, a Swift protocol accepting or returning
Data,Date,URL, orUUIDcannot be implemented as an ordinary Java callback.For example:
With this change, Java can implement that protocol using the existing
java.util.UUIDrepresentation:The generated callback bridge converts the Swift argument into a Java UUID and converts the Java result back into Swift.
Data,Date, andURLcallbacks instead use their existing generated wrapper classes and native value storage.Changes
Data,Date, andURLin callback parameters and results using the existing wrapper conversions.UUIDthroughjava.util.UUID.fromStringandtoString, consistently with the existing JNI-facing UUID API. UUIDs must not be treated as opaque Swift pointer wrappers.java.util.UUIDprojection and dependency mapping to runtime support sowrap-javacan generate callback methods with UUID signatures.FoundationandFoundationEssentials, plus OptionalDataandDate, in generator regressions.Scope
This change enables Foundation values within the types already handled by JNI method extraction. Arrays of Foundation values and Optional
URL/UUIDparameters need separate extraction support and are outside this PR.Validation
swift test --disable-experimental-prebuilts --disable-sandbox: passed../gradlew :Samples:SwiftJavaExtractJNISampleApp:test --no-daemon: passed (278 Java tests, no failures or skips), including the five new runtime tests.swift-format lint --stricton changed Swift files andgit diff --check: passed.Tested with Apple Swift 6.4 and JetBrains Runtime 25.0.2 on macOS.