jextract-jni: Add type parameters to generated java types#648
Merged
ktoso merged 9 commits intoswiftlang:mainfrom Mar 26, 2026
Merged
jextract-jni: Add type parameters to generated java types#648ktoso merged 9 commits intoswiftlang:mainfrom
ktoso merged 9 commits intoswiftlang:mainfrom
Conversation
sidepelican
commented
Mar 26, 2026
| } | ||
|
|
||
| /// A container for receiving Swift generic instances. | ||
| static var _OutSwiftGenericInstance: JavaType { |
Contributor
Author
There was a problem hiding this comment.
This was mistakenly ported to jni-core, so I'll remove the definition from that side later.
Collaborator
There was a problem hiding this comment.
Thanks! I had a feel we'll move one or two too many huh
ktoso
reviewed
Mar 26, 2026
Samples/SwiftJavaExtractJNISampleApp/src/test/java/com/example/swift/GenericTypeTest.java
Outdated
Show resolved
Hide resolved
ktoso
reviewed
Mar 26, 2026
| printer.println() | ||
| let genericClause = | ||
| if decl.swiftNominal.isGeneric { | ||
| "<\(decl.swiftNominal.genericParameters.map(\.name).joined(separator: ", "))>" |
ktoso
reviewed
Mar 26, 2026
|
|
||
| ```java | ||
| public final class MyID implements JNISwiftInstance { | ||
| public final class MyID<T> implements JNISwiftInstance { |
ktoso
approved these changes
Mar 26, 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.
The Java classes introduced in #572 were generated without their generic parameters.
This PR adds them.
To map Swift generic parameter values to their corresponding Java type names, I have added
translateGenericTypeParametertoJNISwift2JavaGenerator.(Adding this function ended up requiring an extra argument for many other functions 🥲)