|
| 1 | +# Supported Features |
| 2 | + |
| 3 | +Summary of features supported by the swift-java interoperability libraries and tools. |
| 4 | + |
| 5 | +## JavaKit Macros |
| 6 | + |
| 7 | +JavaKit supports both directions of interoperability, using Swift macros and source generation |
| 8 | +(via the `swift-java wrap-java` command). |
| 9 | + |
| 10 | +### Java -> Swift |
| 11 | + |
| 12 | +It is possible to use JavaKit macros and the `wrap-java` command to simplify implementing |
| 13 | +Java `native` functions. JavaKit simplifies the type conversions |
| 14 | + |
| 15 | +> tip: This direction of interoperability is covered in the WWDC2025 session 'Explore Swift and Java interoperability' |
| 16 | +> around the [7-minute mark](https://youtu.be/QSHO-GUGidA?si=vUXxphTeO-CHVZ3L&t=448). |
| 17 | +
|
| 18 | +| Feature | Macro support | |
| 19 | +|--------------------------------------------------|-------------------------| |
| 20 | +| Java `static native` method implemented by Swift | ✅ `@JavaImplementation` | |
| 21 | +| **This list is very work in progress** | | |
| 22 | + |
| 23 | +### Swift -> Java |
| 24 | + |
| 25 | + |
| 26 | +> tip: This direction of interoperability is covered in the WWDC2025 session 'Explore Swift and Java interoperability' |
| 27 | +> around the [10-minute mark](https://youtu.be/QSHO-GUGidA?si=QyYP5-p2FL_BH7aD&t=616). |
| 28 | +
|
| 29 | +| Java Feature | Macro support | |
| 30 | +|----------------------------------------|---------------| |
| 31 | +| Java `class` | ✅ | |
| 32 | +| Java class inheritance | ✅ | |
| 33 | +| Java `abstract class` | TODO | |
| 34 | +| Java `enum` | ❌ | |
| 35 | +| Java methods: `static`, member | ✅ `@JavaMethod` | |
| 36 | +| **This list is very work in progress** | | |
| 37 | + |
| 38 | + |
| 39 | +## JExtract: Java -> Swift |
| 40 | + |
| 41 | +SwiftJava's `swift-java jextract` tool automates generating Java bindings from Swift sources. |
| 42 | + |
| 43 | +> tip: This direction of interoperability is covered in the WWDC2025 session 'Explore Swift and Java interoperability' |
| 44 | +> around the [14-minute mark](https://youtu.be/QSHO-GUGidA?si=b9YUwAWDWFGzhRXN&t=842). |
| 45 | +
|
| 46 | + |
| 47 | +| Swift Feature | FFM | JNI | |
| 48 | +|--------------------------------------------------------------------------------------| -------- |-----| |
| 49 | +| | | | |
| 50 | +| Initializers: `class`, `struct` | ✅ | ✅ | |
| 51 | +| Optional Initializers / Throwing Initializers | ❌ | ❌ | |
| 52 | +| Deinitializers: `class`, `struct` | ✅ | ✅ | |
| 53 | +| `enum`, `actor` | ❌ | ❌ | |
| 54 | +| Global Swift `func` | ✅ | ✅ | |
| 55 | +| Class/struct member `func` | ✅ | ✅ | |
| 56 | +| Throwing functions: `func x() throws` | ❌ | ✅ | |
| 57 | +| Typed throws: `func x() throws(E)` | ❌ | ❌ | |
| 58 | +| Stored properties: `var`, `let` (with `willSet`, `didSet`) | ✅ | ✅ | |
| 59 | +| Computed properties: `var` (incl. `throws`) | ✅ / TODO | ✅ | |
| 60 | +| Async functions `func async` and properties: `var { get async {} }` | ❌ | ❌ | |
| 61 | +| Arrays: `[UInt8]`, `[T]` | ❌ | ❌ | |
| 62 | +| Dictionaries: `[String: Int]`, `[K:V]` | ❌ | ❌ | |
| 63 | +| Generic functions | ❌ | ❌ | |
| 64 | +| `Foundation.Data`, `any Foundation.DataProtocol` | ✅ | ❌ | |
| 65 | +| Tuples: `(Int, String)`, `(A, B, C)` | ❌ | ❌ | |
| 66 | +| Protocols: `protocol`, existential parameters `any Collection` | ❌ | ❌ | |
| 67 | +| Optional types: `Int?`, `AnyObject?` | ❌ | ❌ | |
| 68 | +| Primitive types: `Bool`, `Int`, `Int8`, `Int16`, `Int32`, `Int64`, `Float`, `Double` | ✅ | ✅ | |
| 69 | +| Unsigned primitive types: `UInt`, `UInt8`, `UInt16`, `UInt32`, `UInt64` | ❌ | ❌ | |
| 70 | +| String (with copying data) | ✅ | ✅ | |
| 71 | +| Variadic parameters: `T...` | ❌ | ❌ | |
| 72 | +| Parametrer packs / Variadic generics | ❌ | ❌ | |
| 73 | +| Ownership modifiers: `inout`, `borrowing`, `consuming` | ❌ | ❌ | |
| 74 | +| Default parameter values: `func p(name: String = "")` | ❌ | ❌ | |
| 75 | +| Operators: `+`, `-`, user defined | ❌ | ❌ | |
| 76 | +| Subscripts: `subscript()` | ❌ | ❌ | |
| 77 | +| Equatable | ❌ | ❌ | |
| 78 | +| Pointers: `UnsafeRawPointer`, UnsafeBufferPointer (?) | 🟡 | ❌ | |
| 79 | +| Nested types: `struct Hello { struct World {} }` | ❌ | ❌ | |
| 80 | +| Inheritance: `class Caplin: Capybara` | ❌ | ❌ | |
| 81 | +| Closures: `func callMe(maybe: () -> ())` | ❌ | ❌ | |
| 82 | +| Swift type extensions: `extension String { func uppercased() }` | 🟡 | 🟡 | |
| 83 | +| Swift macros (maybe) | ❌ | ❌ | |
| 84 | +| Result builders | ❌ | ❌ | |
| 85 | +| Automatic Reference Counting of class types / lifetime safety | ✅ | ✅ | |
| 86 | +| Value semantic types (e.g. struct copying) | ❌ | ❌ | |
| 87 | +| Opaque types: `func get() -> some Builder`, func take(worker: some Worker) | ❌ | ❌ | |
| 88 | +| Swift concurrency: `func async`, `actor`, `distribued actor` | ❌ | ❌ | |
| 89 | +| | | | |
| 90 | +| | | | |
| 91 | + |
| 92 | +> tip: The list of features may be incomplete, please file an issue if something is unclear or should be clarified in this table. |
0 commit comments