Skip to content

Native Swift Set support for jextract/jni#622

Merged
ktoso merged 1 commit intoswiftlang:mainfrom
ktoso:swift-set-support
Mar 17, 2026
Merged

Native Swift Set support for jextract/jni#622
ktoso merged 1 commit intoswiftlang:mainfrom
ktoso:swift-set-support

Conversation

@ktoso
Copy link
Collaborator

@ktoso ktoso commented Mar 16, 2026

This provides SwiftSet java wrapper which refers to the Swift Set in native memory, unless explicitly copied. This implements the Set interface in Java.

Resolves #612

Disclosure: this was AI assisted and based on the work on Dictionary, since it is very similar the results are also very similar for Set as they are for Dictionary. I've thoroughly reviewed the code and wrote parts of it.

@ktoso ktoso force-pushed the swift-set-support branch from 5af6a20 to b954135 Compare March 16, 2026 07:18
}

@JavaMethod("$size")
public static func _setSize(environment: UnsafeMutablePointer<JNIEnv?>!, pointer: Int64) -> Int32 {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that we must use _set here otherwise we'll nameclash with the dictionary one as those become global funcs... I'll add docs about this

@ktoso ktoso marked this pull request as ready for review March 17, 2026 00:19
@ktoso ktoso merged commit 3228cce into swiftlang:main Mar 17, 2026
121 of 122 checks passed
@ktoso ktoso deleted the swift-set-support branch March 17, 2026 00:19
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/jni: Support native Swift Set use from Java

1 participant