Skip to content

[jextract/jni] Add support for importing nested types#429

Merged
ktoso merged 4 commits into
swiftlang:mainfrom
madsodgaard:nested-types
Nov 7, 2025
Merged

[jextract/jni] Add support for importing nested types#429
ktoso merged 4 commits into
swiftlang:mainfrom
madsodgaard:nested-types

Conversation

@madsodgaard
Copy link
Copy Markdown
Contributor

Adds support for importing nested types such as below. They are imported as nested static classes on the Java side.

public class A {                                                                                                                           
  public init() {}                                                                                                                         
                                                                                                                                           
  public class B {                                                                                                                         
    public init() {}                                                                                                                       
                                                                                                                                           
    public struct C {                                                                                                                      
      public init() {}                                                                                                                     
                                                                                                                                           
      public func g(a: A, b: B, bbc: BB.C) {}                                                                                              
    }                                                                                                                                      
  }                                                                                                                                        
                                                                                                                                           
  public class BB {                                                                                                                        
    public init() {}                                                                                                                       
                                                                                                                                           
    public struct C {                                                                                                                      
      public init() {}                                                                                                                     
    }                                                                                                                                      
  }                                                                                                                                        
                                                                                                                                           
  public func f(a: A, b: A.B, c: A.B.C, bb: BB, bbc: BB.C) {}                                                                              
}                                                                                                                                          
                                                                                                                                           
public enum NestedEnum {                                                                                                                   
  case one(OneStruct)                                                                                                                      
                                                                                                                                           
  public struct OneStruct {                                                                                                                
    public init() {}                                                                                                                       
  }                                                                                                                                        
}                                                                                                                                          

Comment thread Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift Outdated
Copy link
Copy Markdown
Collaborator

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

One nitpick then LGTM, I wonder if you could give the FFM version of that a shot? Should be basically the same hmm

Comment thread Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift Outdated
Comment thread Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift Outdated
@ktoso ktoso merged commit cafcc1d into swiftlang:main Nov 7, 2025
48 checks passed
ktoso pushed a commit to ktoso/swift-java that referenced this pull request Nov 10, 2025
ktoso pushed a commit to ktoso/swift-java that referenced this pull request Nov 10, 2025
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.

2 participants