Skip to content

jextract: support extracting class members - #890

Merged
ktoso merged 5 commits into
swiftlang:mainfrom
AbdAlRahmanGad:Class
Aug 19, 2026
Merged

jextract: support extracting class members#890
ktoso merged 5 commits into
swiftlang:mainfrom
AbdAlRahmanGad:Class

Conversation

@AbdAlRahmanGad

Copy link
Copy Markdown
Member

closes: #835

@AbdAlRahmanGad
AbdAlRahmanGad marked this pull request as ready for review August 18, 2026 10:53
@AbdAlRahmanGad
AbdAlRahmanGad requested a review from ktoso as a code owner August 18, 2026 10:53
public class var classVariable: Int64 {
42
}
// snippet.end

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for adding snippets but we're not using them it seems -- can you add a small bit in FeaturesJextract.md around static methods somewhere:

+### Class methods
+
+Swift `class` methods and computed properties are imported as `static` methods on the generated Java wrapper type.
+
+@TabNavigator {
+   @Tab("Swift") {
+      @Snippet(path: "Snippets/ClassesSwift.swift", slice: "classMembers")
+   }
+   @Tab("Java (JNI)") {
+      @Snippet(path: "Snippets/MySwiftClassTest", slice: "classMembers")
+   }
+   @Tab("Java (FFM)") {
+      @Snippet(path: "Snippets/MySwiftClassTest", slice: "classMembers")
+   }
+}

And make sure we have the snippets for the usage as well

@ktoso

ktoso commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

I think we missed a condition in JNISwift2JavaGenerator.swift:175 in func supportedProtocolRequirements(of type: ExtractedNominalType) -> [ExtractedFunc] { maybe?

@ktoso

ktoso commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Just a minor nit, I think these semantics will work out fine given how we generate code for the java side :)

@AbdAlRahmanGad

Copy link
Copy Markdown
Member Author

I think we missed a condition in JNISwift2JavaGenerator.swift:175 in func supportedProtocolRequirements(of type: ExtractedNominalType) -> [ExtractedFunc] { maybe?

It's actually there, but maybe we should drop the condition since protocols doesn't support class members?

@ktoso

ktoso commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Hm yeah, good question -- we could drop it there I think indeed; This PR is good though so let's land this and we can think about the latter :)

@ktoso
ktoso merged commit a433ddb into swiftlang:main Aug 19, 2026
42 checks passed
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: class methods and vars should be supported

2 participants