@@ -62,11 +62,13 @@ SwiftJava's `swift-java jextract` tool automates generating Java bindings from S
6262| Dictionaries: ` [String: Int] ` , ` [K:V] ` | ❌ | ❌ |
6363| Generic parameters in functions: ` func f<T: A & B>(x: T) ` | ❌ | ✅ |
6464| Generic return values in functions: ` func f<T: A & B>() -> T ` | ❌ | ❌ |
65- | ` Foundation.Data ` , ` any Foundation.DataProtocol ` | ✅ | ❌ |
6665| Tuples: ` (Int, String) ` , ` (A, B, C) ` | ❌ | ❌ |
6766| Protocols: ` protocol ` | ❌ | ✅ |
67+ | Protocols: ` protocol ` with associated types | ❌ | ❌ |
68+ | Existential parameters ` f(x: any SomeProtocol) ` | ❌ | ✅ |
6869| Existential parameters ` f(x: any (A & B)) ` | ❌ | ✅ |
6970| Existential return types ` f() -> any Collection ` | ❌ | ❌ |
71+ | Foundation Data and DataProtocol: ` f(x: any DataProtocol) -> Data ` | ✅ | ❌ |
7072| Opaque parameters: ` func take(worker: some Builder) -> some Builder ` | ❌ | ✅ |
7173| Opaque return types: ` func get() -> some Builder ` | ❌ | ❌ |
7274| Optional parameters: ` func f(i: Int?, class: MyClass?) ` | ✅ | ✅ |
@@ -272,9 +274,11 @@ try (var arena = SwiftArena.ofConfined()) {
272274
273275### Protocols
274276
275- > Note: Protocols are currently only supported in JNI mode.
277+ > Note: Protocols are currently only supported in JNI mode.
278+ >
279+ > With the exception of ` any DataProtocol ` which is handled as ` Foundation.Data ` in the FFM mode.
276280
277- Protocols are imported as Java ` interface ` s. For now, we require that all
281+ Swift ` protocol ` types are imported as Java ` interface ` s. For now, we require that all
278282concrete types of an interface wrap a Swift instance. In the future, we will add support
279283for providing Java-based implementations of interfaces, that you can pass to Java functions.
280284
@@ -305,6 +309,10 @@ will be exported as
305309``` java
306310< S extends A & B , T1 extends C , T2 extends D > void f(S x, T1 y, T2 z)
307311```
312+ On the Java side, only SwiftInstance implementing types may be passed;
313+ so this isn't a way for compatibility with just any arbitrary Java interfaces,
314+ but specifically, for allowing passing concrete binding types generated by jextract from Swift types
315+ which conform a to a given Swift protocol.
308316
309- #### Return types
317+ #### Returning protocol types
310318Protocols are not yet supported as return types.
0 commit comments