-
Notifications
You must be signed in to change notification settings - Fork 66
Description
Commit : up to date
Context : While to build Samples/JavaKitSampleApp with adding .interoperabilityMode(.Cxx) in swiftSettings, I noticed the error message like below
macro expansion @JavaImplementation:2:6: error: method cannot be marked '@_cdecl' because the type of the parameter 1 cannot be represented in Objective-C
- /Users/zhaoyu/repos/swift-java/Samples/JavaKitSampleApp/Sources/JavaKitExample/JavaKitExample.swift:105:2: note: expanded code originates here 20 | } 21 | 22 | @JavaImplementation("com.example.swift.HelloSwift") | - note: in expansion of macro 'JavaImplementation' on extension of class 'HelloSwift' here
23 | extension HelloSwift: HelloSwiftNativeMethods {
24 | @JavaMethod
:
103 | throw SwiftWrappedError.message(message)
104 | }
105 | }
+--- macro expansion @JavaImplementation ---------------------------
| 1 | @cdecl("Java_com_example_swift_HelloSwift_sayHello")
| 2 | func $s14JavaKitExample1_0A14ImplementationfMp_8sayHellofMu(environment: UnsafeMutablePointer<JNIEnv?>!, thisObj: jobject, _ i: Int32.JNIType, _ j: Int32.JNIType) -> Int32.JNIType {
| | `- error: method cannot be marked '@cdecl' because the type of the parameter 1 cannot be represented in Objective-C
| 3 | let obj = HelloSwift(javaThis: thisObj, environment: environment!)
| 4 | return obj.sayHello(: Int32(fromJNI: i, in: environment!), _: Int32(fromJNI: j, in: environment!))
+-------------------------------------------------------------------
106 |
Steps to reproduce:
- git clone https://github.com/swiftlang/swift-java.git
- cd swift-java/Samples/JavaKitSamleApp
- Add a line .interoperabilityMode(.Cxx) in the swiftSettings of the target JavaKitSample
- swift build
Environment:
% swift --version
Apple Swift version 6.2 (swift-6.2-RELEASE)
Target: arm64-apple-macosx15.0
Build config: +assertions
% java --version
openjdk 25 2025-09-16 LTS
OpenJDK Runtime Environment Temurin-25+36 (build 25+36-LTS)
OpenJDK 64-Bit Server VM Temurin-25+36 (build 25+36-LTS, mixed mode, sharing)
macOS 15.4.1 (24E263) on a Mac mini M2