jextract/ffm: Support throwing funcs in FFM mode#658
Merged
ktoso merged 5 commits intoswiftlang:mainfrom Mar 31, 2026
Merged
Conversation
Fix misleading Java output path in regeneration script
The script echoed ${TYPE}.java but the generator may remap the
Java class name (e.g. SwiftJavaError -> SwiftJavaErrorException).
Print the output directory instead of guessing the filename.
cleanups
ktoso
commented
Mar 31, 2026
|
|
||
| /// Wraps a Swift `any Error` value so it can be passed across the FFI boundary | ||
| /// as a reference-counted heap object | ||
| public final class SwiftJavaError { |
Collaborator
Author
There was a problem hiding this comment.
This is to avoid guessing if the struct we're throwing needs to be retained or now, we just wrap them all into this
ktoso
added a commit
to ktoso/swift-java
that referenced
this pull request
Mar 31, 2026
* jextract/ffm: support throwing functions in ffm
* script to jextract parts of SwiftKit, like SwiftJavaError
* jextract/ffm: initial SwiftJavaError support in FFM mode
Fix misleading Java output path in regeneration script
The script echoed ${TYPE}.java but the generator may remap the
Java class name (e.g. SwiftJavaError -> SwiftJavaErrorException).
Print the output directory instead of guessing the filename.
cleanups
* re-run the ./scripts/swiftkit-ffm-generate-bindings.sh
* fix formatting and license
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.
resolves long standing missing feature #34
I introduce a new Java error type that we use to "type erase" the thrown errors when Java gets them. In future we can do typed throws.
We also jextract and commit the wrapper for it so we don't have bootstrap issues, i.e. we can build without having to run jextract first:
org.swift.swiftkit.ffm.generated.SwiftJavaErrorExceptionThis is similar to the issue that wrap-java has with comitted generated wrappers in SwiftJava.
Added runtime and source gen tests