Skip to content

Commit 8e0687b

Browse files
authored
Merge branch 'swiftlang:main' into main
2 parents f6ad15f + 67c8153 commit 8e0687b

File tree

190 files changed

+1331
-350
lines changed

Some content is hidden

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

190 files changed

+1331
-350
lines changed

Benchmarks/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ let package = Package(
5151
.executableTarget(
5252
name: "JavaApiCallBenchmarks",
5353
dependencies: [
54-
.product(name: "CJNI", package: "swift-java"),
54+
.product(name: "CSwiftJavaJNI", package: "swift-java"),
5555
.product(name: "SwiftJava", package: "swift-java"),
5656
.product(name: "JavaNet", package: "swift-java"),
5757
.product(name: "Benchmark", package: "package-benchmark"),

Package.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ let package = Package(
101101
),
102102

103103
.library(
104-
name: "CJNI",
105-
targets: ["CJNI"]
104+
name: "CSwiftJavaJNI",
105+
targets: ["CSwiftJavaJNI"]
106106
),
107107

108108
.library(
@@ -237,7 +237,7 @@ let package = Package(
237237
.target(
238238
name: "SwiftJava",
239239
dependencies: [
240-
"CJNI",
240+
"CSwiftJavaJNI",
241241
"SwiftJavaMacros",
242242
"JavaTypes",
243243
"SwiftJavaConfigurationShared", // for Configuration reading at runtime
@@ -359,7 +359,7 @@ let package = Package(
359359
),
360360

361361
.target(
362-
name: "CJNI",
362+
name: "CSwiftJavaJNI",
363363
swiftSettings: [
364364
.swiftLanguageMode(.v5),
365365
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"])

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ cd Samples/JavaKitSampleApp
138138
To run a simple example app showcasing the jextract (Java calling Swift) approach you can:
139139
140140
```bash
141-
./gradlew Samples:SwiftKitSampleApp:run
141+
./gradlew Samples:SwiftJavaExtractFFMSampleApp:run
142142
```
143143
144144
This will also generate the necessary sources (by invoking jextract, extracting the `Sources/ExampleSwiftLibrary`)
@@ -152,7 +152,7 @@ Please refer to the [Samples](Samples) directory for more sample apps which show
152152
153153
You can run Swift [ordo-one/package-benchmark](https://github.com/ordo-one/package-benchmark) and OpenJDK [JMH](https://github.com/openjdk/jmh) benchmarks in this project.
154154
155-
Swift benchmarks are located under `Benchmarks/` and JMH benchmarks are currently part of the SwiftKit sample project: `Samples/SwiftKitSampleApp/src/jmh` because they depend on generated sources from the sample.
155+
Swift benchmarks are located under `Benchmarks/` and JMH benchmarks are currently part of the SwiftKit sample project: `Samples/SwiftJavaExtractFFMSampleApp/src/jmh` because they depend on generated sources from the sample.
156156
157157
### Swift benchmarks
158158
@@ -168,8 +168,8 @@ swift package benchmark
168168
In order to run JMH benchmarks you can:
169169
170170
```bash
171-
cd Samples/SwiftKitSampleApp
172-
gradle jmh
171+
cd Samples/SwiftJavaExtractFFMSampleApp
172+
./gradlew jmh
173173
```
174174
175175
Please read documentation of both performance testing tools and understand that results must be interpreted and not just taken at face value. Benchmarking is tricky and environment sensitive task, so please be careful when constructing and reading benchmarks and their results. If in doubt, please reach out on the forums.
@@ -183,8 +183,8 @@ To view the rendered docc documentation you can use the docc preview command:
183183
```bash
184184
xcrun docc preview Sources/SwiftJavaDocumentation/Documentation.docc
185185
186-
# OR JavaKit to view JavaKit documentation:
187-
# xcrun docc preview Sources/SwiftJNI/Documentation.docc
186+
# OR SwiftJava to view SwiftJava documentation:
187+
# xcrun docc preview Sources/SwiftJava/Documentation.docc
188188
189189
# ========================================
190190
# Starting Local Preview Server

Samples/JavaDependencySampleApp/Package.swift

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

Samples/SwiftJavaExtractFFMSampleApp/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ let package = Package(
6464
name: "MySwiftLibrary",
6565
dependencies: [
6666
.product(name: "SwiftJava", package: "swift-java"),
67-
.product(name: "CJNI", package: "swift-java"),
67+
.product(name: "CSwiftJavaJNI", package: "swift-java"),
6868
.product(name: "SwiftKitSwift", package: "swift-java"),
6969
],
7070
exclude: [

Samples/SwiftJavaExtractFFMSampleApp/Sources/MySwiftLibrary/jni/JNIImplementations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
import SwiftJava
16-
import CJNI
16+
import CSwiftJavaJNI
1717

1818
@JavaClass("com.example.swift.HelloJava2Swift")
1919
open class HelloJava2Swift: JavaObject {

Samples/SwiftJavaExtractJNISampleApp/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ let package = Package(
6161
name: "MySwiftLibrary",
6262
dependencies: [
6363
.product(name: "SwiftJava", package: "swift-java"),
64-
.product(name: "CJNI", package: "swift-java"),
64+
.product(name: "CSwiftJavaJNI", package: "swift-java"),
6565
.product(name: "SwiftKitSwift", package: "swift-java"),
6666
],
6767
exclude: [
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
public class ConcreteProtocolAB: ProtocolA, ProtocolB {
16+
public let constantA: Int64
17+
public let constantB: Int64
18+
public var mutable: Int64 = 0
19+
20+
public func name() -> String {
21+
return "ConcreteProtocolAB"
22+
}
23+
24+
public init(constantA: Int64, constantB: Int64) {
25+
self.constantA = constantA
26+
self.constantB = constantB
27+
}
28+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
public protocol ProtocolA {
16+
var constantA: Int64 { get }
17+
var mutable: Int64 { get set }
18+
19+
func name() -> String
20+
}
21+
22+
public func takeProtocol(_ proto1: any ProtocolA, _ proto2: some ProtocolA) -> Int64 {
23+
return proto1.constantA + proto2.constantA
24+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
public protocol ProtocolB {
16+
var constantB: Int64 { get }
17+
}
18+
19+
public func takeCombinedProtocol(_ proto: some ProtocolA & ProtocolB) -> Int64 {
20+
return proto.constantA + proto.constantB
21+
}
22+
23+
public func takeGenericProtocol<First: ProtocolA, Second: ProtocolB>(_ proto1: First, _ proto2: Second) -> Int64 {
24+
return proto1.constantA + proto2.constantB
25+
}
26+
27+
public func takeCombinedGenericProtocol<T: ProtocolA & ProtocolB>(_ proto: T) -> Int64 {
28+
return proto.constantA + proto.constantB
29+
}

0 commit comments

Comments
 (0)