Skip to content

Commit f653047

Browse files
committed
Merge branch 'main' into fix-config
2 parents 0109bdc + 1de7279 commit f653047

File tree

65 files changed

+1345
-277
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1345
-277
lines changed

.github/workflows/pull_request.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ jobs:
2626
name: Documentation check
2727
runs-on: ubuntu-latest
2828
container:
29-
image: 'swift:6.1-noble'
29+
image: 'swift:6.2-noble'
3030
strategy:
3131
fail-fast: true
3232
matrix:
33-
swift_version: ['6.1.3']
33+
swift_version: ['6.2']
3434
os_version: ['jammy']
3535
jdk_vendor: ['corretto']
3636
steps:
@@ -48,7 +48,7 @@ jobs:
4848
strategy:
4949
fail-fast: true
5050
matrix:
51-
swift_version: ['6.1.3', 'nightly']
51+
swift_version: ['6.2', 'nightly']
5252
os_version: ['jammy']
5353
jdk_vendor: ['corretto']
5454
container:
@@ -74,7 +74,7 @@ jobs:
7474
strategy:
7575
fail-fast: true
7676
matrix:
77-
swift_version: ['6.2.0']
77+
swift_version: ['6.2']
7878
os_version: ['macos']
7979
jdk_vendor: ['corretto']
8080
env:
@@ -98,7 +98,7 @@ jobs:
9898
strategy:
9999
fail-fast: true
100100
matrix:
101-
swift_version: ['6.2.0']
101+
swift_version: ['6.2']
102102
os_version: ['jammy']
103103
jdk_vendor: ['corretto']
104104
container:
@@ -118,7 +118,7 @@ jobs:
118118
strategy:
119119
fail-fast: true
120120
matrix:
121-
swift_version: ['6.2.0']
121+
swift_version: ['6.2']
122122
os_version: ['jammy']
123123
jdk_vendor: ['corretto']
124124
container:
@@ -140,7 +140,7 @@ jobs:
140140
strategy:
141141
fail-fast: false
142142
matrix:
143-
swift_version: ['6.1.3', 'nightly']
143+
swift_version: ['6.2', 'nightly']
144144
os_version: ['jammy']
145145
jdk_vendor: ['corretto']
146146
container:
@@ -162,7 +162,7 @@ jobs:
162162
strategy:
163163
fail-fast: false
164164
matrix:
165-
swift_version: ['6.2.0']
165+
swift_version: ['6.2']
166166
os_version: ['macos']
167167
jdk_vendor: ['corretto']
168168
env:
@@ -182,7 +182,7 @@ jobs:
182182
strategy:
183183
fail-fast: false
184184
matrix:
185-
swift_version: ['6.1.3', 'nightly']
185+
swift_version: ['6.2', 'nightly']
186186
os_version: ['jammy']
187187
jdk_vendor: ['corretto']
188188
sample_app: [ # TODO: use a reusable-workflow to generate those names
@@ -210,7 +210,7 @@ jobs:
210210
strategy:
211211
fail-fast: false
212212
matrix:
213-
swift_version: ['6.2.0'] # no nightly testing on macOS
213+
swift_version: ['6.2'] # no nightly testing on macOS
214214
os_version: ['macos']
215215
jdk_vendor: ['corretto']
216216
sample_app: [ # TODO: use a reusable-workflow to generate those names

Package.swift

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 6.0
1+
// swift-tools-version: 6.2
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import CompilerPluginSupport
@@ -169,9 +169,14 @@ let package = Package(
169169

170170
// Support library written in Swift for SwiftKit "Java"
171171
.library(
172-
name: "SwiftKitSwift",
172+
name: "SwiftJavaRuntimeSupport",
173+
targets: ["SwiftJavaRuntimeSupport"]
174+
),
175+
176+
.library(
177+
name: "SwiftRuntimeFunctions",
173178
type: .dynamic,
174-
targets: ["SwiftKitSwift"]
179+
targets: ["SwiftRuntimeFunctions"]
175180
),
176181

177182
.library(
@@ -197,7 +202,7 @@ let package = Package(
197202

198203
],
199204
dependencies: [
200-
.package(url: "https://github.com/swiftlang/swift-syntax", from: "601.0.1"),
205+
.package(url: "https://github.com/swiftlang/swift-syntax", from: "602.0.0"),
201206
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.5.0"),
202207
.package(url: "https://github.com/apple/swift-system", from: "1.4.0"),
203208

@@ -213,7 +218,8 @@ let package = Package(
213218
name: "SwiftJavaDocumentation",
214219
dependencies: [
215220
"SwiftJava",
216-
"SwiftKitSwift",
221+
"SwiftJavaRuntimeSupport",
222+
"SwiftRuntimeFunctions",
217223
]
218224
),
219225

@@ -351,8 +357,19 @@ let package = Package(
351357
]
352358
),
353359
.target(
354-
name: "SwiftKitSwift",
355-
dependencies: [],
360+
name: "SwiftJavaRuntimeSupport",
361+
dependencies: [
362+
"CSwiftJavaJNI",
363+
"SwiftJava"
364+
],
365+
swiftSettings: [
366+
.swiftLanguageMode(.v5),
367+
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"])
368+
]
369+
),
370+
371+
.target(
372+
name: "SwiftRuntimeFunctions",
356373
swiftSettings: [
357374
.swiftLanguageMode(.v5),
358375
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"])

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ It is possible to generate Swift bindings to Java libraries using SwiftJava by u
5858

5959
Required language/runtime versions:
6060
- **JDK 17+**, any recent JDK installation should be sufficient, as only general reflection and JNI APIs are used by this integratio
61-
- **Swift 6.0.x**, because the library uses modern Swift macros
61+
- **Swift 6.2.x**, because the library uses modern Swift macros
6262

6363
**swift-java jextract**
6464

@@ -73,7 +73,7 @@ This does require the use of the relatively recent [JEP-454: Foreign Function &
7373
This is the primary way we envision calling Swift code from server-side Java libraries and applications.
7474

7575
Required language/runtime versions:
76-
- **Swift 6.1**, because of dependence on rich swift interface files
76+
- **Swift 6.2**, because of dependence on rich swift interface files
7777
- **JDK 25+**
7878
- We are validating the implementation using the currently supported non-LTE release, which at present means JDK-25.
7979

@@ -85,7 +85,7 @@ This mode is more limited in some performance and flexibility that it can offer,
8585
We recommend this mode when FFM is not available, or wide ranging deployment compatibility is your priority. When performance is paramaunt, we recommend the FFM mode instead.
8686

8787
Required language/runtime versions:
88-
- **Swift 6.1**, because of dependence on rich swift interface files
88+
- **Swift 6.2**, because of dependence on rich swift interface files
8989
- **Java 7+**, including
9090

9191

@@ -94,7 +94,7 @@ Required language/runtime versions:
9494
This project contains multiple builds, living side by side together.
9595

9696
You will need to have:
97-
- Swift (6.1.x+)
97+
- Swift (6.2.x+)
9898
- Java (25+ for FFM, even though we support lower JDK targets)
9999
- Gradle (installed by "Gradle wrapper" automatically when you run gradle through `./gradlew`)
100100

@@ -104,7 +104,7 @@ Install **Swift**, the easiest way to do this is to use **Swiftly**: [swift.org/
104104
This should automatically install a recent Swift, but you can always make sure by running:
105105

106106
```bash
107-
swiftly install 6.1.2 --use
107+
swiftly install 6.2 --use
108108
```
109109

110110
Install a recent enough Java distribution. We validate this project using Corretto so you can choose to use that as well,
@@ -229,4 +229,4 @@ xcrun docc preview Sources/SwiftJavaDocumentation/Documentation.docc
229229

230230
**This project is under active development. We welcome feedback about any issues you encounter.**
231231

232-
There is no guarantee about API stability until the project reaches a 1.0 release.
232+
There is no guarantee about API stability until the project reaches a 1.0 release.

Samples/SwiftAndJavaJarSampleLib/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ let package = Package(
6363
.target(
6464
name: "MySwiftLibrary",
6565
dependencies: [
66-
.product(name: "SwiftKitSwift", package: "swift-java"),
66+
.product(name: "SwiftRuntimeFunctions", package: "swift-java"),
6767
],
6868
exclude: [
6969
"swift-java.config",

Samples/SwiftJavaExtractFFMSampleApp/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ let package = Package(
6565
dependencies: [
6666
.product(name: "SwiftJava", package: "swift-java"),
6767
.product(name: "CSwiftJavaJNI", package: "swift-java"),
68-
.product(name: "SwiftKitSwift", package: "swift-java"),
68+
.product(name: "SwiftRuntimeFunctions", package: "swift-java"),
6969
],
7070
exclude: [
7171
"swift-java.config",

Samples/SwiftJavaExtractJNISampleApp/Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 6.0
1+
// swift-tools-version: 6.2
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import CompilerPluginSupport
@@ -62,7 +62,7 @@ let package = Package(
6262
dependencies: [
6363
.product(name: "SwiftJava", package: "swift-java"),
6464
.product(name: "CSwiftJavaJNI", package: "swift-java"),
65-
.product(name: "SwiftKitSwift", package: "swift-java"),
65+
.product(name: "SwiftJavaRuntimeSupport", package: "swift-java"),
6666
],
6767
exclude: [
6868
"swift-java.config"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2025 Apple Inc. and the Swift.org project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of Swift.org project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
import SwiftJava
16+
17+
public func asyncSum(i1: Int64, i2: Int64) async -> Int64 {
18+
return i1 + i2
19+
}
20+
21+
public func asyncSleep() async throws {
22+
try await Task.sleep(for: .milliseconds(500))
23+
}
24+
25+
public func asyncCopy(myClass: MySwiftClass) async throws -> MySwiftClass {
26+
let new = MySwiftClass(x: myClass.x, y: myClass.y)
27+
try await Task.sleep(for: .milliseconds(500))
28+
return new
29+
}
30+
31+
public func asyncOptional(i: Int64) async throws -> Int64? {
32+
try await Task.sleep(for: .milliseconds(100))
33+
return i
34+
}
35+
36+
public func asyncThrows() async throws {
37+
throw MySwiftError.swiftError
38+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2025 Apple Inc. and the Swift.org project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of Swift.org project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
enum MySwiftError: Error {
16+
case swiftError
17+
}

Samples/SwiftJavaExtractJNISampleApp/Sources/MySwiftLibrary/MySwiftLibrary.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#if os(Linux)
2121
import Glibc
22+
#elseif os(Android)
23+
import Android
2224
#else
2325
import Darwin.C
2426
#endif

Samples/SwiftJavaExtractJNISampleApp/Sources/MySwiftLibrary/Optionals.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public func optionalJavaKitLong(input: Optional<JavaLong>) -> Int64? {
6262
}
6363
}
6464

65+
public func optionalThrowing() throws -> Int64? {
66+
throw MySwiftError.swiftError
67+
}
68+
6569
public func multipleOptionals(
6670
input1: Optional<Int8>,
6771
input2: Optional<Int16>,

0 commit comments

Comments
 (0)