Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ extension HelloSwift: HelloSwiftNativeMethods {
print("Caught Java error: \(error)")
}

// Make sure that the thread safe class is sendable
let threadSafe: Sendable = ThreadSafeHelperClass(environment: javaEnvironment)

return i * j
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2024 Apple Inc. and the Swift.org project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

package com.example.swift;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.RUNTIME)
public @interface ThreadSafe {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.swift;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing license header?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops updated


@ThreadSafe
public class ThreadSafeHelperClass {
public ThreadSafeHelperClass() { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"classes" : {
"com.example.swift.HelloSwift" : "HelloSwift",
"com.example.swift.HelloSubclass" : "HelloSubclass",
"com.example.swift.JavaKitSampleMain" : "JavaKitSampleMain"
"com.example.swift.JavaKitSampleMain" : "JavaKitSampleMain",
"com.example.swift.ThreadSafeHelperClass" : "ThreadSafeHelperClass"
}
}
Loading