diff --git a/Samples/SwiftJavaExtractJNISampleApp/Sources/MySwiftLibrary/ProtocolWithStatic.swift b/Samples/SwiftJavaExtractJNISampleApp/Sources/MySwiftLibrary/ProtocolWithStatic.swift new file mode 100644 index 00000000..9936646a --- /dev/null +++ b/Samples/SwiftJavaExtractJNISampleApp/Sources/MySwiftLibrary/ProtocolWithStatic.swift @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2025 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 +// +//===----------------------------------------------------------------------===// + +public protocol ProtocolWithStatic { + // static requirements are not yet supported. + static func myFunc() -> Int + static var value: Int64 { get } + init() +} diff --git a/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift b/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift index 14b15217..00f5d672 100644 --- a/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift +++ b/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift @@ -145,16 +145,23 @@ extension JNISwift2JavaGenerator { printer.printBraceBlock("public interface \(decl.swiftNominal.name)\(extendsString)") { printer in for initializer in decl.initializers { - printFunctionDowncallMethods(&printer, initializer, skipMethodBody: true) - printer.println() + self.logger.debug("Skipping static method '\(initializer.name)'") } for method in decl.methods { + if method.isStatic { + self.logger.debug("Skipping static method '\(method.name)'") + continue + } printFunctionDowncallMethods(&printer, method, skipMethodBody: true) printer.println() } for variable in decl.variables { + if variable.isStatic { + self.logger.debug("Skipping static property '\(variable.name)'") + continue + } printFunctionDowncallMethods(&printer, variable, skipMethodBody: true) printer.println() } diff --git a/Sources/SwiftJavaDocumentation/Documentation.docc/SupportedFeatures.md b/Sources/SwiftJavaDocumentation/Documentation.docc/SupportedFeatures.md index 2f9b7fda..66a87cb5 100644 --- a/Sources/SwiftJavaDocumentation/Documentation.docc/SupportedFeatures.md +++ b/Sources/SwiftJavaDocumentation/Documentation.docc/SupportedFeatures.md @@ -65,6 +65,7 @@ SwiftJava's `swift-java jextract` tool automates generating Java bindings from S | Tuples: `(Int, String)`, `(A, B, C)` | ❌ | ❌ | | Protocols: `protocol` | ❌ | ✅ | | Protocols: `protocol` with associated types | ❌ | ❌ | +| Protocols static requirements: `static func`, `init(rawValue:)` | ❌ | ❌ | | Existential parameters `f(x: any SomeProtocol)` (excepts `Any`) | ❌ | ✅ | | Existential parameters `f(x: any (A & B)) ` | ❌ | ✅ | | Existential return types `f() -> any Collection` | ❌ | ❌ |