Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This repository contains two approaches to Swift/Java interoperability.

- Swift library (`JavaKit`) and bindings generator that allows a Swift program to make use of Java libraries by wrapping Java classes in corresponding Swift types, allowing Swift to directly call any wrapped Java API.
- Swift library (`SwiftJava`) and bindings generator that allows a Swift program to make use of Java libraries by wrapping Java classes in corresponding Swift types, allowing Swift to directly call any wrapped Java API.
- The `swift-java` tool which which offers automated ways to import or "extract" bindings to sources or libraries in either language. The results are bindings for Swift or Java.

## :construction: :construction: :construction: Early Development :construction: :construction: :construction:
Expand All @@ -19,11 +19,11 @@ The primary purpose of this repository is to create an environment for collabora

This project consists of different modules which have different Swift and Java runtime requirements.

## JavaKit macros
## SwiftJava macros

JavaKit is a Swift library offering macros which simplify writing JNI code "by hand" but also calling Java code from Swift.
SwiftJava is a Swift library offering macros which simplify writing JNI code "by hand" but also calling Java code from Swift.

It is possible to generate Swift bindings to Java libraries using JavaKit by using the `swift-java wrap-java` command.
It is possible to generate Swift bindings to Java libraries using SwiftJava by using the `swift-java wrap-java` command.

Required language/runtime versions:
- **JDK 17+**, any recent JDK installation should be sufficient, as only general reflection and JNI APIs are used by this integration
Expand Down Expand Up @@ -124,12 +124,12 @@ Please always use the gradle wrapper (`./gradlew`) to make sure to use the appro

Sample apps are located in the `Samples/` directory, and they showcase full "roundtrip" usage of the library and/or tools.

#### JavaKit (Swift -> Java)
#### SwiftJava (Swift -> Java)

To run a simple app showcasing a Swift process calling into a Java library you can run:

```bash
cd Samples/JavaKitSampleApp
cd Samples/SwiftJavaExtractFFMSampleApp
./ci-validate.sh # which is just `swift build` and a `java -cp ...` invocation of the compiled program
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Summary of features supported by the swift-java interoperability libraries and t

## Overview

JavaKit supports both directions of interoperability, using Swift macros and source generation
SwiftJava supports both directions of interoperability, using Swift macros and source generation
(via the `swift-java wrap-java` command).

### Java -> Swift

It is possible to use JavaKit macros and the `wrap-java` command to simplify implementing
Java `native` functions. JavaKit simplifies the type conversions
It is possible to use SwiftJava macros and the `wrap-java` command to simplify implementing
Java `native` functions. SwiftJava simplifies the type conversions

> tip: This direction of interoperability is covered in the WWDC2025 session 'Explore Swift and Java interoperability'
> around the [7-minute mark](https://youtu.be/QSHO-GUGidA?si=vUXxphTeO-CHVZ3L&t=448).
Expand Down Expand Up @@ -74,8 +74,8 @@ SwiftJava's `swift-java jextract` tool automates generating Java bindings from S
| Optional parameters: `func f(i: Int?, class: MyClass?)` | ✅ | ✅ |
| Optional return types: `func f() -> Int?`, `func g() -> MyClass?` | ❌ | ✅ |
| Primitive types: `Bool`, `Int`, `Int8`, `Int16`, `Int32`, `Int64`, `Float`, `Double` | ✅ | ✅ |
| Parameters: JavaKit wrapped types `JavaLong`, `JavaInteger` | ❌ | ✅ |
| Return values: JavaKit wrapped types `JavaLong`, `JavaInteger` | ❌ | ❌ |
| Parameters: SwiftJava wrapped types `JavaLong`, `JavaInteger` | ❌ | ✅ |
| Return values: SwiftJava wrapped types `JavaLong`, `JavaInteger` | ❌ | ❌ |
| Unsigned primitive types: `UInt`, `UInt8`, `UInt16`, `UInt32`, `UInt64` | ✅ * | ✅ * |
| String (with copying data) | ✅ | ✅ |
| Variadic parameters: `T...` | ❌ | ❌ |
Expand Down
Loading