Skip to content

Commit cfef570

Browse files
committed
Add to the testing app
1 parent 826cfe4 commit cfef570

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

Samples/JavaKitSampleApp/Sources/JavaKitExample/Java2Swift.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"classes" : {
33
"com.example.swift.HelloSwift" : "HelloSwift",
44
"com.example.swift.HelloSubclass" : "HelloSubclass",
5-
"com.example.swift.JavaKitSampleMain" : "JavaKitSampleMain"
5+
"com.example.swift.JavaKitSampleMain" : "JavaKitSampleMain",
6+
"com.example.swift.ThreadSafeHelperClass" : "ThreadSafeHelperClass"
67
}
78
}

Samples/JavaKitSampleApp/Sources/JavaKitExample/JavaKitExample.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ extension HelloSwift: HelloSwiftNativeMethods {
7676
print("Caught Java error: \(error)")
7777
}
7878

79+
// Make sure that the thread safe class is sendable
80+
let threadSafe: Sendable = ThreadSafeHelperClass(environment: javaEnvironment)
81+
7982
return i * j
8083
}
8184

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2024 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+
package com.example.swift;
16+
17+
import java.lang.annotation.Retention;
18+
import java.lang.annotation.RetentionPolicy;
19+
20+
@Retention(RetentionPolicy.RUNTIME)
21+
public @interface ThreadSafe {
22+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.example.swift;
2+
3+
@ThreadSafe
4+
public class ThreadSafeHelperClass {
5+
public ThreadSafeHelperClass() { }
6+
}

0 commit comments

Comments
 (0)