Skip to content

SwiftJavaJNICore support#6

Merged
marcprux merged 10 commits into
mainfrom
swift-java-jni-core
Mar 27, 2026
Merged

SwiftJavaJNICore support#6
marcprux merged 10 commits into
mainfrom
swift-java-jni-core

Conversation

@marcprux
Copy link
Copy Markdown
Member

@marcprux marcprux commented Mar 27, 2026

This PR adds a SWIFT_JAVA_JNI_CORE constant, (temporarily) controlled by a build environment variable SWIFT_JAVA_JNI_CORE, that adds a dependency on https://github.com/swiftlang/swift-java-jni-core.git and retroactively conforms JObject to JavaValue, which will enable interoperability between Skip's bridged Kotlin types and SwiftJava @JavaClass values.

@cla-bot cla-bot Bot added the cla-signed label Mar 27, 2026
@ktoso
Copy link
Copy Markdown

ktoso commented Mar 27, 2026

Happy to see this first step :) what’s the follow-up plans here?

@marcprux
Copy link
Copy Markdown
Member Author

Happy to see this first step :) what’s the follow-up plans here?

Good question 😁 This is my "toe in the water" to see what breaks and what works. Fortunately, everything is working great so far.

My goal is to eventually eliminate this skiptools/swift-jni repo altogether and have the two major dependents rely directly on swift-java-jni-core: https://github.com/skiptools/skip-bridge and https://github.com/skiptools/swift-android-native. For the latter, most of the work has already been done by @colemancda in our collaborative fork at https://github.com/swift-android-sdk/swift-android-native (which I'm hoping will replace the upstream skiptools version eventually), and his PureSwift/Android Android API mappings using SwiftJava have already been ported to depend on swift-android-native (in PureSwift/Android#40).

Moving skip-bridge to depend solely on swift-java-jni-core will require quite a bit more work (you can get a taste for the generated Swift bridges here), so I expect swift-jni will stick around at least as a compatibility shim for some time to come (I'd like to rename it to something more obscure, though).

Once this PR gets merged and a new release is cut, though, the immediate win will be that Skip-bridged Kotlin types will be able to interact directly with @JavaClass enhanced types like, say, PureSwift/Android/Activity.swift. At least, at the JavaValue level. One thing I'm wondering is whether it might makes sense to move AnyJavaObject from swift-java to swift-java-jni-core, since that would also let Skip adopt that protocol. I haven't thought it through yet or looked into what other related types would need to come along, and I'm not sure what specific additional benefits would be gained. But it seems like AnyJavaObject is a natural fit for Skip-bridged types.

@marcprux marcprux merged commit a77d66d into main Mar 27, 2026
5 checks passed
@marcprux marcprux deleted the swift-java-jni-core branch March 27, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants