From b0c246af7760ee0f51bea8e181fa8033330902f9 Mon Sep 17 00:00:00 2001 From: NakaokaRei Date: Mon, 5 Oct 2026 03:15:32 +1300 Subject: [PATCH] JNI: support consumers with C++ interoperability enabled Preserve the runtime's C JNI types in generated entry points and calls. Expose typed JNI interface getters and an object-value factory so Android consumers do not reimport JNI signatures using the NDK's C++ wrappers. Update generator and macro expectations for the preserved types. Allow the JavaKit and JNI extraction samples to opt into C++ interoperability on consumer targets only. Exercise this mode in existing stable Swift CI jobs, including one Android configuration, and rerun Gradle tests across configurations without reusing a daemon from another Swift toolchain. Validation: 820 package tests; normal and C++ sample tests on macOS and Linux ARM64; Android JNI sample build; hello-cpp-swift emulator execution. Scoped act format, shell, and sample checks passed; the full GitHub Actions workflow and Linux AMD64 execution remain unverified. --- .github/workflows/pull_request.yml | 19 ++ Samples/JavaKitSampleApp/Package.swift | 13 +- .../Package.swift | 13 +- .../ci-validate.sh | 7 +- ...wift2JavaGenerator+NativeTranslation.swift | 56 ++-- ...ift2JavaGenerator+SwiftThunkPrinting.swift | 22 +- Sources/JExtractSwiftLib/JavaParameter.swift | 18 +- Sources/SwiftJava/JNITypes.swift | 179 ++++++++++++ .../SwiftJavaMacros/ImplementsJavaMacro.swift | 7 +- Tests/JExtractSwiftTests/ByteArrayTests.swift | 12 +- .../JExtractSwiftTests/DataImportTests.swift | 8 +- Tests/JExtractSwiftTests/DateTests.swift | 8 +- Tests/JExtractSwiftTests/IfConfigTests.swift | 2 +- .../JExtractSwiftTests/JNI/JNIArrayTest.swift | 20 +- .../JNI/JNIAsyncTests.swift | 76 ++--- .../JNI/JNIClassTests.swift | 16 +- .../JNI/JNIClosureTests.swift | 264 +++++++++--------- .../JNI/JNIDictionaryTest.swift | 12 +- .../JNI/JNIDistributedActorTests.swift | 4 +- .../JExtractSwiftTests/JNI/JNIEnumTests.swift | 6 +- .../JNI/JNIGenericCombinationTests.swift | 28 +- .../JNI/JNIGenericTypeTests.swift | 26 +- .../JNI/JNIIntConversionChecksTests.swift | 24 +- .../JNI/JNIJavaKitTests.swift | 8 +- .../JNI/JNIJobjectBridgeTests.swift | 4 +- .../JNI/JNIModuleTests.swift | 14 +- .../JNI/JNINestedTypesTests.swift | 8 +- .../JNI/JNIOperatorsTests.swift | 2 +- .../JNI/JNIOptionalTests.swift | 18 +- .../JNI/JNIProtocolTests.swift | 30 +- Tests/JExtractSwiftTests/JNI/JNISetTest.swift | 10 +- .../JNI/JNIStructTests.swift | 4 +- .../JNI/JNISubscriptsTests.swift | 8 +- .../JNI/JNITupleTests.swift | 10 +- .../JNI/JNIVariablesTests.swift | 24 +- .../SpecializationTests.swift | 4 +- .../TimeIntervalTests.swift | 4 +- .../TypealiasResolutionTests.swift | 4 +- Tests/JExtractSwiftTests/UUIDTests.swift | 4 +- .../JavaImplementationMacroTests.swift | 16 +- 40 files changed, 615 insertions(+), 397 deletions(-) create mode 100644 Sources/SwiftJava/JNITypes.swift diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index bdf459660..ae7501a14 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -258,6 +258,13 @@ jobs: perl -pi -e "s#(download_and_extract_toolchain \".ANDROID_SDK_TAG\"\))#\1\n PATH=\\\$(dirname \\\$SWIFT_EXECUTABLE_FOR_ANDROID_SDK):\\\$PATH\n echo \"path is now \\\$PATH\"#" install-and-build-with-sdk.sh chmod 500 install-and-build-with-sdk.sh ./install-and-build-with-sdk.sh --android --build-command="swift build" --android-sdk-triple="${{ matrix.sdk_triple }}" --android-ndk-version="${{ matrix.ndk_version }}" ${{ matrix.swift_version }} + - name: Verify Android JNI consumer with C++ interoperability + if: matrix.swift_version == '6.3' && matrix.sdk_triple == 'aarch64-unknown-linux-android28' && matrix.ndk_version == 'r27d' + working-directory: Samples/SwiftJavaExtractJNISampleApp + env: + CXX_INTEROP: '1' + SWIFT_JAVA_VERBOSE: true + run: ./install-and-build-with-sdk.sh --android --build-command="swift build" --android-sdk-triple="${{ matrix.sdk_triple }}" --android-ndk-version="${{ matrix.ndk_version }}" ${{ matrix.swift_version }} verify-samples: name: Sample ${{ matrix.sample_app }} (${{ matrix.os_version }} swift:${{ matrix.swift_version }} jdk:${{matrix.jdk_vendor}}) @@ -296,6 +303,12 @@ jobs: ${{ runner.os }}-swift${{ matrix.swift_version }}-sample- - name: "Verify sample: ${{ matrix.sample_app }}" run: .github/scripts/validate_sample.sh Samples/${{ matrix.sample_app }} + - name: Verify JNI consumer with C++ interoperability + if: matrix.swift_version == '6.3' && (matrix.sample_app == 'JavaKitSampleApp' || matrix.sample_app == 'SwiftJavaExtractJNISampleApp') + env: + CXX_INTEROP: '1' + SWIFT_JAVA_VERBOSE: true + run: .github/scripts/validate_sample.sh Samples/${{ matrix.sample_app }} verify-samples-macos: @@ -335,6 +348,12 @@ jobs: ${{ runner.os }}-swift${{ matrix.swift_version }}-sample- - name: "Verify sample ${{ matrix.sample_app }}" run: .github/scripts/validate_sample.sh Samples/${{ matrix.sample_app }} + - name: Verify JNI consumer with C++ interoperability + if: matrix.swift_version == '6.3' && (matrix.sample_app == 'JavaKitSampleApp' || matrix.sample_app == 'SwiftJavaExtractJNISampleApp') + env: + CXX_INTEROP: '1' + SWIFT_JAVA_VERBOSE: true + run: .github/scripts/validate_sample.sh Samples/${{ matrix.sample_app }} linkage-test: name: Linkage test (noble swift:6.3) diff --git a/Samples/JavaKitSampleApp/Package.swift b/Samples/JavaKitSampleApp/Package.swift index f9746f2f4..e5d31d925 100644 --- a/Samples/JavaKitSampleApp/Package.swift +++ b/Samples/JavaKitSampleApp/Package.swift @@ -4,6 +4,11 @@ import CompilerPluginSupport import PackageDescription +// Enable C++ interoperability only in the consumer targets, not their dependencies. +let sampleSwiftSettings: [SwiftSetting] = + [.swiftLanguageMode(.v5)] + + (Context.environment["CXX_INTEROP"] == "1" ? [.interoperabilityMode(.Cxx)] : []) + let package = Package( name: "JavaKitSampleApp", platforms: [ @@ -35,9 +40,7 @@ let package = Package( .product(name: "JavaUtilJar", package: "swift-java"), .product(name: "ArgumentParser", package: "swift-argument-parser"), ], - swiftSettings: [ - .swiftLanguageMode(.v5) - ], + swiftSettings: sampleSwiftSettings, plugins: [ .plugin(name: "JavaCompilerPlugin", package: "swift-java"), .plugin(name: "SwiftJavaPlugin", package: "swift-java"), @@ -49,9 +52,7 @@ let package = Package( dependencies: [ "JavaKitExample" ], - swiftSettings: [ - .swiftLanguageMode(.v5) - ] + swiftSettings: sampleSwiftSettings ), ] ) diff --git a/Samples/SwiftJavaExtractJNISampleApp/Package.swift b/Samples/SwiftJavaExtractJNISampleApp/Package.swift index 4f86b1a9e..7b2bad34d 100644 --- a/Samples/SwiftJavaExtractJNISampleApp/Package.swift +++ b/Samples/SwiftJavaExtractJNISampleApp/Package.swift @@ -4,6 +4,11 @@ import CompilerPluginSupport import PackageDescription +// Enable C++ interoperability only in the consumer targets, not their dependencies. +let sampleSwiftSettings: [SwiftSetting] = + [.swiftLanguageMode(.v5)] + + (Context.environment["CXX_INTEROP"] == "1" ? [.interoperabilityMode(.Cxx)] : []) + let package = Package( name: "JExtractJNISampleApp", platforms: [ @@ -34,9 +39,7 @@ let package = Package( exclude: [ "swift-java.config" ], - swiftSettings: [ - .swiftLanguageMode(.v5) - ], + swiftSettings: sampleSwiftSettings, plugins: [ .plugin(name: "JExtractSwiftPlugin", package: "swift-java") ] @@ -50,9 +53,7 @@ let package = Package( exclude: [ "swift-java.config" ], - swiftSettings: [ - .swiftLanguageMode(.v5) - ], + swiftSettings: sampleSwiftSettings, plugins: [ .plugin(name: "JExtractSwiftPlugin", package: "swift-java") ] diff --git a/Samples/SwiftJavaExtractJNISampleApp/ci-validate.sh b/Samples/SwiftJavaExtractJNISampleApp/ci-validate.sh index d62a09102..9b3612126 100755 --- a/Samples/SwiftJavaExtractJNISampleApp/ci-validate.sh +++ b/Samples/SwiftJavaExtractJNISampleApp/ci-validate.sh @@ -42,5 +42,8 @@ fi # FIXME: disable prebuilts until prebuilt swift-syntax isn't broken on 6.2 anymore: https://github.com/swiftlang/swift-java/issues/418 swift build $DISABLE_EXPERIMENTAL_PREBUILTS --disable-sandbox -./gradlew run -./gradlew test +# A reused daemon can resolve `swift` using the PATH from an older toolchain. +./gradlew --no-daemon run +# Gradle does not track the Swift library as a test input. Rerun tests when +# switching C++ interoperability so the second configuration is exercised too. +./gradlew --no-daemon test --rerun-tasks diff --git a/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+NativeTranslation.swift b/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+NativeTranslation.swift index 229e48f55..aa856c2a5 100644 --- a/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+NativeTranslation.swift +++ b/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+NativeTranslation.swift @@ -1515,8 +1515,8 @@ extension JNISwift2JavaGenerator { let typeMetadataVariableName = "\(inner)typeMetadata$" printer.print( """ - let \(pointerVariableName) = environment.interface.CallLongMethodA(environment, \(inner), _JNIMethodIDCache.JNISwiftInstance.memoryAddress, []) - let \(typeMetadataVariableName) = environment.interface.CallLongMethodA(environment, \(inner), _JNIMethodIDCache.JNISwiftInstance.typeMetadataAddress, []) + let \(pointerVariableName) = environment.swiftInterface.CallLongMethodA(environment, \(inner), _JNIMethodIDCache.JNISwiftInstance.memoryAddress, []) + let \(typeMetadataVariableName) = environment.swiftInterface.CallLongMethodA(environment, \(inner), _JNIMethodIDCache.JNISwiftInstance.typeMetadataAddress, []) """ ) let existentialName = NativeSwiftConversionStep.extractSwiftProtocolValue( @@ -1533,7 +1533,7 @@ extension JNISwift2JavaGenerator { // or if its a custom class implementing the interface. if allowsJavaImplementations { printer.printBraceBlock( - "if environment.interface.IsInstanceOf(environment, \(inner), _JNIMethodIDCache.JNISwiftInstance.class) != 0" + "if environment.swiftInterface.IsInstanceOf(environment, \(inner), _JNIMethodIDCache.JNISwiftInstance.class) != 0" ) { printer in printStandardJExtractBlock(&printer) } @@ -1702,15 +1702,15 @@ extension JNISwift2JavaGenerator { printer.print( """ - let class$ = environment.interface.GetObjectClass(environment, \(placeholder)) - let methodID$ = environment.interface.GetMethodID(environment, class$, "\(methodName)", "\(methodSignature.mangledName)")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [\(arguments.joined(separator: .comma))] + let class$ = environment.swiftInterface.GetObjectClass(environment, \(placeholder)) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "\(methodName)", "\(methodSignature.mangledName)")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [\(arguments.joined(separator: .comma))] """ ) let upcall = - "environment.interface.\(nativeResult.javaType.jniCallMethodAName)(environment, \(placeholder), methodID$, arguments$)" + "environment.swiftInterface.\(nativeResult.javaType.jniCallMethodAName)(environment, \(placeholder), methodID$, arguments$)" let result = nativeResult.conversion.render(&printer, upcall) if nativeResult.javaType.isVoid { @@ -1818,7 +1818,7 @@ extension JNISwift2JavaGenerator { let discriminatorParameterName ): if !returnType.isVoid { - printer.print("let \(resultName): \(returnType.jniTypeName)") + printer.print("let \(resultName): \(returnType.swiftJNITypeName)") } printer.printIfBlock("let innerResult$ = \(placeholder)") { printer in let inner = inner.render(&printer, "innerResult$") @@ -1828,7 +1828,7 @@ extension JNISwift2JavaGenerator { printer.print( """ var flag$ = Int8(1) - environment.interface.SetByteArrayRegion(environment, \(discriminatorParameterName), 0, 1, &flag$) + environment.swiftInterface.SetByteArrayRegion(environment, \(discriminatorParameterName), 0, 1, &flag$) """ ) } @@ -1839,7 +1839,7 @@ extension JNISwift2JavaGenerator { printer.print( """ var flag$ = Int8(0) - environment.interface.SetByteArrayRegion(environment, \(discriminatorParameterName), 0, 1, &flag$) + environment.swiftInterface.SetByteArrayRegion(environment, \(discriminatorParameterName), 0, 1, &flag$) """ ) } @@ -1854,10 +1854,10 @@ extension JNISwift2JavaGenerator { printer.printBraceBlock("do") { printer in printer.print( """ - environment.interface.SetLongField(environment, \(outArgumentName), _JNIMethodIDCache._OutSwiftGenericInstance.selfPointer, \(inner)) + environment.swiftInterface.SetLongField(environment, \(outArgumentName), _JNIMethodIDCache._OutSwiftGenericInstance.selfPointer, \(inner)) let metadataPointer = unsafeBitCast(\(swiftFunctionResultType).self, to: UnsafeRawPointer.self) let metadataPointerBits$ = Int64(Int(bitPattern: metadataPointer)) - environment.interface.SetLongField(environment, \(outArgumentName), _JNIMethodIDCache._OutSwiftGenericInstance.selfTypePointer, metadataPointerBits$.getJNIValue(in: environment)) + environment.swiftInterface.SetLongField(environment, \(outArgumentName), _JNIMethodIDCache._OutSwiftGenericInstance.selfTypePointer, metadataPointerBits$.getJNIValue(in: environment)) """ ) } @@ -1869,8 +1869,8 @@ extension JNISwift2JavaGenerator { printer.print( """ let (selfPointerBits$, selfTypePointerBits$) = \(boxed) - environment.interface.SetLongField(environment, \(outArgumentName), _JNIMethodIDCache._OutSwiftGenericInstance.selfPointer, selfPointerBits$.getJNIValue(in: environment)) - environment.interface.SetLongField(environment, \(outArgumentName), _JNIMethodIDCache._OutSwiftGenericInstance.selfTypePointer, selfTypePointerBits$.getJNIValue(in: environment)) + environment.swiftInterface.SetLongField(environment, \(outArgumentName), _JNIMethodIDCache._OutSwiftGenericInstance.selfPointer, selfPointerBits$.getJNIValue(in: environment)) + environment.swiftInterface.SetLongField(environment, \(outArgumentName), _JNIMethodIDCache._OutSwiftGenericInstance.selfTypePointer, selfTypePointerBits$.getJNIValue(in: environment)) """ ) } @@ -1941,20 +1941,20 @@ extension JNISwift2JavaGenerator { // Global ref all indirect returns for outParameter in nativeFunctionSignature.result.outParameters { printer.print( - "nonisolated(unsafe) let \(outParameter.name) = environment.interface.NewGlobalRef(environment, \(outParameter.name))" + "nonisolated(unsafe) let \(outParameter.name) = environment.swiftInterface.NewGlobalRef(environment, \(outParameter.name))" ) globalRefs.append(outParameter.name) } // We also need to global ref any objects passed in for parameter in nativeFunctionSignature.parameters.flatMap(\.parameters) where !parameter.type.isPrimitive { - printer.print("nonisolated(unsafe) let \(parameter.name) = environment.interface.NewGlobalRef(environment, \(parameter.name))") + printer.print("nonisolated(unsafe) let \(parameter.name) = environment.swiftInterface.NewGlobalRef(environment, \(parameter.name))") globalRefs.append(parameter.name) } printer.print( """ - nonisolated(unsafe) let globalFuture = environment.interface.NewGlobalRef(environment, result_future) + nonisolated(unsafe) let globalFuture = environment.swiftInterface.NewGlobalRef(environment, result_future) """ ) @@ -1993,7 +1993,7 @@ extension JNISwift2JavaGenerator { printer.print("\(tryAwaitString) \(placeholderWithoutTry)") printer.print("environment = try! JavaVirtualMachine.shared().environment()") printer.print( - "_ = environment.interface.CallBooleanMethodA(environment, globalFuture, \(completeMethodID), [jvalue(l: nil)])" + "_ = environment.swiftInterface.CallBooleanMethodA(environment, globalFuture, \(completeMethodID), [JNITypes.objectValue(nil)])" ) } else { printer.print("let swiftResult$ = \(tryAwaitString) \(placeholderWithoutTry)") @@ -2013,7 +2013,7 @@ extension JNISwift2JavaGenerator { } printer.print( - "_ = environment.interface.CallBooleanMethodA(environment, globalFuture, \(completeMethodID), [jvalue(l: \(result))])" + "_ = environment.swiftInterface.CallBooleanMethodA(environment, globalFuture, \(completeMethodID), [JNITypes.objectValue(\(result))])" ) } } @@ -2026,7 +2026,7 @@ extension JNISwift2JavaGenerator { // Defer might on any thread, so we need to attach environment. printer.print("let deferEnvironment = try! JavaVirtualMachine.shared().environment()") for globalRef in globalRefs { - printer.print("deferEnvironment.interface.DeleteGlobalRef(deferEnvironment, \(globalRef))") + printer.print("deferEnvironment.swiftInterface.DeleteGlobalRef(deferEnvironment, \(globalRef))") } } if isThrowing { @@ -2038,8 +2038,8 @@ extension JNISwift2JavaGenerator { printer.print( """ let catchEnvironment = try! JavaVirtualMachine.shared().environment() - let exception = catchEnvironment.interface.NewObjectA(catchEnvironment, _JNIMethodIDCache.Exception.class, _JNIMethodIDCache.Exception.constructWithMessage, [String(describing: error).getJValue(in: catchEnvironment)]) - _ = catchEnvironment.interface.CallBooleanMethodA(catchEnvironment, globalFuture, \(completeExceptionallyMethodID), [jvalue(l: exception)]) + let exception = catchEnvironment.swiftInterface.NewObjectA(catchEnvironment, _JNIMethodIDCache.Exception.class, _JNIMethodIDCache.Exception.constructWithMessage, [String(describing: error).getJValue(in: catchEnvironment)]) + _ = catchEnvironment.swiftInterface.CallBooleanMethodA(catchEnvironment, globalFuture, \(completeExceptionallyMethodID), [JNITypes.objectValue(exception)]) """ ) } @@ -2107,9 +2107,9 @@ extension JNISwift2JavaGenerator { let releaseMode = mutable ? "0" : "jint(JNI_ABORT)" printer.print( """ - let \(countVar) = Int(environment.interface.GetArrayLength(environment, \(inner))) - let \(ptrVar) = environment.interface.GetByteArrayElements(environment, \(inner), nil)! - defer { environment.interface.ReleaseByteArrayElements(environment, \(inner), \(ptrVar), \(releaseMode)) } + let \(countVar) = Int(environment.swiftInterface.GetArrayLength(environment, \(inner))) + let \(ptrVar) = environment.swiftInterface.GetByteArrayElements(environment, \(inner), nil)! + defer { environment.swiftInterface.ReleaseByteArrayElements(environment, \(inner), \(ptrVar), \(releaseMode)) } let \(rbpVar) = \(bufferPointerType)(start: \(ptrVar), count: \(countVar)) """ ) @@ -2138,12 +2138,12 @@ extension JNISwift2JavaGenerator { let setMethodName = element.javaType.jniSetArrayRegionMethodName printer.print("var element_\(element.index)_jni$ = \(converted)") printer.print( - "environment.interface.\(setMethodName)(environment, \(element.outParamName), 0, 1, &element_\(element.index)_jni$)" + "environment.swiftInterface.\(setMethodName)(environment, \(element.outParamName), 0, 1, &element_\(element.index)_jni$)" ) case .class, .array: printer.print("let element_\(element.index)_jni$ = \(converted)") printer.print( - "environment.interface.SetObjectArrayElement(environment, \(element.outParamName), 0, element_\(element.index)_jni$)" + "environment.swiftInterface.SetObjectArrayElement(environment, \(element.outParamName), 0, element_\(element.index)_jni$)" ) } } diff --git a/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+SwiftThunkPrinting.swift b/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+SwiftThunkPrinting.swift index 229512e24..244cb3c45 100644 --- a/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+SwiftThunkPrinting.swift +++ b/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+SwiftThunkPrinting.swift @@ -887,15 +887,17 @@ extension JNISwift2JavaGenerator { self.generatedCDeclSymbolNames.append(cName) let translatedParameters = parameters.map { - "\($0.name): \($0.type.jniTypeName)" + "\($0.name): \($0.type.swiftJNITypeName)" } + // Use the Swift alias defined in the runtime's C import context. Importing + // Android's JNIEnv directly in a C++-enabled client makes it a C++ struct. let thunkParameters = [ - "environment: UnsafeMutablePointer!", - "thisClass: jclass", + "environment: JNIEnvironment!", + "thisClass: JNITypes.jclass", ] + translatedParameters - let thunkReturnType = resultType != .void ? " -> \(resultType.jniTypeName)" : "" + let thunkReturnType = resultType != .void ? " -> \(resultType.swiftJNITypeName)" : "" // TODO: Think about function overloads printer.printBraceBlock( @@ -939,7 +941,7 @@ extension JNISwift2JavaGenerator { methods: [wrapMemoryAddressUnsafeMethod] ) - static var javaClass: jclass { + static var javaClass: JNITypes.jclass { cache.javaClass } @@ -980,7 +982,7 @@ extension JNISwift2JavaGenerator { printer.printBraceBlock(bridgeDeclaration) { printer in printer.print("typealias SwiftType = \(bridgedSwiftType)") printer.println() - printer.printBraceBlock("static var javaClass: jclass") { printer in + printer.printBraceBlock("static var javaClass: JNITypes.jclass") { printer in printer.print("\(cacheName).javaClass") } printer.println() @@ -1152,15 +1154,15 @@ extension JNISwift2JavaGenerator { let resultType = nativeSignature.result.javaType let translatedParameters = parameters.map { - "\($0.name): \($0.type.jniTypeName)" + "\($0.name): \($0.type.swiftJNITypeName)" } let thunkParameters = [ - "environment: UnsafeMutablePointer!", - "thisClass: jclass", + "environment: JNIEnvironment!", + "thisClass: JNITypes.jclass", ] + translatedParameters - let thunkReturnType = resultType != .void ? " -> \(resultType.jniTypeName)" : "" + let thunkReturnType = resultType != .void ? " -> \(resultType.swiftJNITypeName)" : "" let signature = #"static func \#(decl.openerMethodName)(\#(thunkParameters.joined(separator: .comma)))\#(thunkReturnType)"# if !skipMethodBody { diff --git a/Sources/JExtractSwiftLib/JavaParameter.swift b/Sources/JExtractSwiftLib/JavaParameter.swift index ac3e7304e..210c2fa1b 100644 --- a/Sources/JExtractSwiftLib/JavaParameter.swift +++ b/Sources/JExtractSwiftLib/JavaParameter.swift @@ -14,6 +14,18 @@ import SwiftJavaJNICore +extension JavaType { + /// Preserve the runtime's C JNI reference types in C++-enabled consumers. + var swiftJNITypeName: String { + switch self { + case .class, .array: + "JNITypes.\(jniTypeName)" + default: + jniTypeName + } + } +} + /// Represent a parameter in Java code. struct JavaParameter { enum ParameterType: Equatable, CustomStringConvertible { @@ -52,10 +64,10 @@ struct JavaParameter { } } - var jniTypeName: String { + var swiftJNITypeName: String { switch self { - case .concrete(let type): type.jniTypeName - case .generic: "jobject?" + case .concrete(let type): type.swiftJNITypeName + case .generic: "JNITypes.jobject?" } } diff --git a/Sources/SwiftJava/JNITypes.swift b/Sources/SwiftJava/JNITypes.swift new file mode 100644 index 000000000..6f239880f --- /dev/null +++ b/Sources/SwiftJava/JNITypes.swift @@ -0,0 +1,179 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2026 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 +// +//===----------------------------------------------------------------------===// + +import CSwiftJavaJNI +import SwiftJavaJNICore + +/// JNI reference and value types as imported by the runtime in C mode. +/// +/// Use these aliases in generated code so C++-enabled consumers share the +/// runtime's types instead of importing Android's C++ JNI wrapper types. +public enum JNITypes { + public typealias jobject = CSwiftJavaJNI.jobject + public typealias jclass = CSwiftJavaJNI.jclass + public typealias jstring = CSwiftJavaJNI.jstring + public typealias jarray = CSwiftJavaJNI.jarray + public typealias jobjectArray = CSwiftJavaJNI.jobjectArray + public typealias jbooleanArray = CSwiftJavaJNI.jbooleanArray + public typealias jbyteArray = CSwiftJavaJNI.jbyteArray + public typealias jcharArray = CSwiftJavaJNI.jcharArray + public typealias jshortArray = CSwiftJavaJNI.jshortArray + public typealias jintArray = CSwiftJavaJNI.jintArray + public typealias jlongArray = CSwiftJavaJNI.jlongArray + public typealias jfloatArray = CSwiftJavaJNI.jfloatArray + public typealias jdoubleArray = CSwiftJavaJNI.jdoubleArray + public typealias jthrowable = CSwiftJavaJNI.jthrowable + public typealias jweak = CSwiftJavaJNI.jweak + public typealias jvalue = CSwiftJavaJNI.jvalue + + /// Construct the union in C mode, where its object field uses the runtime's type. + public static func objectValue(_ object: jobject?) -> jvalue { + jvalue(l: object) + } +} + +/// The JNI operations used by generated code, with signatures fixed in C mode. +/// +/// Reading fields of the imported C function table directly in a C++ consumer +/// reimports their signatures with the NDK's C++ JNI types. These Swift getters +/// keep both sides of each call in the runtime's C import context. +public struct JNIInterface { + fileprivate let environment: JNIEnvironment + + public var GetObjectClass: @convention(c) (JNIEnvironment?, jobject?) -> jclass? { + environment.interface.GetObjectClass + } + + public var GetMethodID: @convention(c) (JNIEnvironment?, jclass?, UnsafePointer?, UnsafePointer?) -> jmethodID? { + environment.interface.GetMethodID + } + + public var IsInstanceOf: @convention(c) (JNIEnvironment?, jobject?, jclass?) -> jboolean { + environment.interface.IsInstanceOf + } + + public var NewGlobalRef: @convention(c) (JNIEnvironment?, jobject?) -> jobject? { + environment.interface.NewGlobalRef + } + + public var DeleteGlobalRef: @convention(c) (JNIEnvironment?, jobject?) -> Void { + environment.interface.DeleteGlobalRef + } + + public var DeleteLocalRef: @convention(c) (JNIEnvironment?, jobject?) -> Void { + environment.interface.DeleteLocalRef + } + + public var NewObjectA: @convention(c) (JNIEnvironment?, jclass?, jmethodID?, UnsafePointer?) -> jobject? { + environment.interface.NewObjectA + } + + public var SetLongField: @convention(c) (JNIEnvironment?, jobject?, jfieldID?, jlong) -> Void { + environment.interface.SetLongField + } + + public var GetArrayLength: @convention(c) (JNIEnvironment?, jarray?) -> jsize { + environment.interface.GetArrayLength + } + + public var GetByteArrayElements: @convention(c) (JNIEnvironment?, jbyteArray?, UnsafeMutablePointer?) -> UnsafeMutablePointer? { + environment.interface.GetByteArrayElements + } + + public var ReleaseByteArrayElements: @convention(c) (JNIEnvironment?, jbyteArray?, UnsafeMutablePointer?, jint) -> Void { + environment.interface.ReleaseByteArrayElements + } + + public var SetObjectArrayElement: @convention(c) (JNIEnvironment?, jobjectArray?, jsize, jobject?) -> Void { + environment.interface.SetObjectArrayElement + } + + public var CallObjectMethodA: @convention(c) (JNIEnvironment?, jobject?, jmethodID?, UnsafePointer?) -> jobject? { + environment.interface.CallObjectMethodA + } + + public var CallBooleanMethodA: @convention(c) (JNIEnvironment?, jobject?, jmethodID?, UnsafePointer?) -> jboolean { + environment.interface.CallBooleanMethodA + } + + public var CallByteMethodA: @convention(c) (JNIEnvironment?, jobject?, jmethodID?, UnsafePointer?) -> jbyte { + environment.interface.CallByteMethodA + } + + public var CallCharMethodA: @convention(c) (JNIEnvironment?, jobject?, jmethodID?, UnsafePointer?) -> jchar { + environment.interface.CallCharMethodA + } + + public var CallShortMethodA: @convention(c) (JNIEnvironment?, jobject?, jmethodID?, UnsafePointer?) -> jshort { + environment.interface.CallShortMethodA + } + + public var CallIntMethodA: @convention(c) (JNIEnvironment?, jobject?, jmethodID?, UnsafePointer?) -> jint { + environment.interface.CallIntMethodA + } + + public var CallLongMethodA: @convention(c) (JNIEnvironment?, jobject?, jmethodID?, UnsafePointer?) -> jlong { + environment.interface.CallLongMethodA + } + + public var CallFloatMethodA: @convention(c) (JNIEnvironment?, jobject?, jmethodID?, UnsafePointer?) -> jfloat { + environment.interface.CallFloatMethodA + } + + public var CallDoubleMethodA: @convention(c) (JNIEnvironment?, jobject?, jmethodID?, UnsafePointer?) -> jdouble { + environment.interface.CallDoubleMethodA + } + + public var CallVoidMethodA: @convention(c) (JNIEnvironment?, jobject?, jmethodID?, UnsafePointer?) -> Void { + environment.interface.CallVoidMethodA + } + + public var SetBooleanArrayRegion: @convention(c) (JNIEnvironment?, jbooleanArray?, jsize, jsize, UnsafePointer?) -> Void { + environment.interface.SetBooleanArrayRegion + } + + public var SetByteArrayRegion: @convention(c) (JNIEnvironment?, jbyteArray?, jsize, jsize, UnsafePointer?) -> Void { + environment.interface.SetByteArrayRegion + } + + public var SetCharArrayRegion: @convention(c) (JNIEnvironment?, jcharArray?, jsize, jsize, UnsafePointer?) -> Void { + environment.interface.SetCharArrayRegion + } + + public var SetShortArrayRegion: @convention(c) (JNIEnvironment?, jshortArray?, jsize, jsize, UnsafePointer?) -> Void { + environment.interface.SetShortArrayRegion + } + + public var SetIntArrayRegion: @convention(c) (JNIEnvironment?, jintArray?, jsize, jsize, UnsafePointer?) -> Void { + environment.interface.SetIntArrayRegion + } + + public var SetLongArrayRegion: @convention(c) (JNIEnvironment?, jlongArray?, jsize, jsize, UnsafePointer?) -> Void { + environment.interface.SetLongArrayRegion + } + + public var SetFloatArrayRegion: @convention(c) (JNIEnvironment?, jfloatArray?, jsize, jsize, UnsafePointer?) -> Void { + environment.interface.SetFloatArrayRegion + } + + public var SetDoubleArrayRegion: @convention(c) (JNIEnvironment?, jdoubleArray?, jsize, jsize, UnsafePointer?) -> Void { + environment.interface.SetDoubleArrayRegion + } +} + +extension JNIEnvironment { + public var swiftInterface: JNIInterface { + JNIInterface(environment: self) + } +} diff --git a/Sources/SwiftJavaMacros/ImplementsJavaMacro.swift b/Sources/SwiftJavaMacros/ImplementsJavaMacro.swift index bfcde7b30..094a9cca6 100644 --- a/Sources/SwiftJavaMacros/ImplementsJavaMacro.swift +++ b/Sources/SwiftJavaMacros/ImplementsJavaMacro.swift @@ -105,11 +105,12 @@ extension JavaImplementationMacro: PeerMacro { parametersClause.parameters.remove(at: environmentIndex) } - // Map the parameters. + // Map the parameters using JNIEnvironment from the runtime's C import + // context: Android's JNIEnv becomes a C++ struct in C++-enabled clients. let cParameters: [FunctionParameterSyntax] = [ - "environment: UnsafeMutablePointer!", - isStatic ? "thisClass: jclass" : "thisObj: jobject", + "environment: JNIEnvironment!", + isStatic ? "thisClass: JNITypes.jclass" : "thisObj: JNITypes.jobject", ] + parametersClause.parameters.map { param in param.with(\.type, "\(param.type).JNIType") diff --git a/Tests/JExtractSwiftTests/ByteArrayTests.swift b/Tests/JExtractSwiftTests/ByteArrayTests.swift index 9d79ea16b..626b2ba0d 100644 --- a/Tests/JExtractSwiftTests/ByteArrayTests.swift +++ b/Tests/JExtractSwiftTests/ByteArrayTests.swift @@ -199,7 +199,7 @@ final class ByteArrayTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024acceptArray___3B") - public func Java_com_example_swift_SwiftModule__00024acceptArray___3B(environment: UnsafeMutablePointer!, thisClass: jclass, array: jbyteArray?) { + public func Java_com_example_swift_SwiftModule__00024acceptArray___3B(environment: JNIEnvironment!, thisClass: JNITypes.jclass, array: JNITypes.jbyteArray?) { SwiftModule.acceptArray(array: [UInt8](fromJNI: array, in: environment)) } """ @@ -232,7 +232,7 @@ final class ByteArrayTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024returnArray__") - public func Java_com_example_swift_SwiftModule__00024returnArray__(environment: UnsafeMutablePointer!, thisClass: jclass) -> jbyteArray? { + public func Java_com_example_swift_SwiftModule__00024returnArray__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> JNITypes.jbyteArray? { return SwiftModule.returnArray().getJNILocalRefValue(in: environment) } """ @@ -266,10 +266,10 @@ final class ByteArrayTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024receiveBuffer___3B") - public func Java_com_example_swift_SwiftModule__00024receiveBuffer___3B(environment: UnsafeMutablePointer!, thisClass: jclass, data: jbyteArray?) { - let data$count = Int(environment.interface.GetArrayLength(environment, data)) - let data$ptr = environment.interface.GetByteArrayElements(environment, data, nil)! - defer { environment.interface.ReleaseByteArrayElements(environment, data, data$ptr, jint(JNI_ABORT)) } + public func Java_com_example_swift_SwiftModule__00024receiveBuffer___3B(environment: JNIEnvironment!, thisClass: JNITypes.jclass, data: JNITypes.jbyteArray?) { + let data$count = Int(environment.swiftInterface.GetArrayLength(environment, data)) + let data$ptr = environment.swiftInterface.GetByteArrayElements(environment, data, nil)! + defer { environment.swiftInterface.ReleaseByteArrayElements(environment, data, data$ptr, jint(JNI_ABORT)) } let data$rbp = UnsafeRawBufferPointer(start: data$ptr, count: data$count) SwiftModule.receiveBuffer(data: data$rbp) } diff --git a/Tests/JExtractSwiftTests/DataImportTests.swift b/Tests/JExtractSwiftTests/DataImportTests.swift index a1ad07745..371c31b97 100644 --- a/Tests/JExtractSwiftTests/DataImportTests.swift +++ b/Tests/JExtractSwiftTests/DataImportTests.swift @@ -515,7 +515,7 @@ final class DataImportTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024acceptData__J") - public func Java_com_example_swift_SwiftModule__00024acceptData__J(environment: UnsafeMutablePointer!, thisClass: jclass, data: jlong) { + public func Java_com_example_swift_SwiftModule__00024acceptData__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, data: jlong) { """ ] ) @@ -546,7 +546,7 @@ final class DataImportTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024returnData__") - public func Java_com_example_swift_SwiftModule__00024returnData__(environment: UnsafeMutablePointer!, thisClass: jclass) -> jlong { + public func Java_com_example_swift_SwiftModule__00024returnData__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> jlong { """ ] ) @@ -645,7 +645,7 @@ final class DataImportTests { detectChunkByInitialLines: 1, expectedChunks: [ """ - public func Java_com_example_swift_SwiftModule__00024processData__Ljava_lang_Object_2(environment: UnsafeMutablePointer!, thisClass: jclass, data: jobject?) -> jlong { + public func Java_com_example_swift_SwiftModule__00024processData__Ljava_lang_Object_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, data: JNITypes.jobject?) -> jlong { """, """ result$.initialize(to: SwiftModule.processData(data: dataswiftObject$)) @@ -669,7 +669,7 @@ final class DataImportTests { detectChunkByInitialLines: 1, expectedChunks: [ """ - public func Java_com_example_swift_SwiftModule__00024verify__Ljava_lang_Object_2Ljava_lang_Object_2(environment: UnsafeMutablePointer!, thisClass: jclass, first: jobject?, second: jobject?) -> jboolean { + public func Java_com_example_swift_SwiftModule__00024verify__Ljava_lang_Object_2Ljava_lang_Object_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, first: JNITypes.jobject?, second: JNITypes.jobject?) -> jboolean { """, """ return SwiftModule.verify(first: firstswiftObject$, second: secondswiftObject$).getJNILocalRefValue(in: environment) diff --git a/Tests/JExtractSwiftTests/DateTests.swift b/Tests/JExtractSwiftTests/DateTests.swift index bf5e9ef8e..9570c1e57 100644 --- a/Tests/JExtractSwiftTests/DateTests.swift +++ b/Tests/JExtractSwiftTests/DateTests.swift @@ -34,7 +34,7 @@ struct DateTests { [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024acceptDate__J") - public func Java_com_example_swift_SwiftModule__00024acceptDate__J(environment: UnsafeMutablePointer!, thisClass: jclass, date: jlong) { + public func Java_com_example_swift_SwiftModule__00024acceptDate__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, date: jlong) { """ ], ) @@ -84,7 +84,7 @@ struct DateTests { [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024returnDate__") - public func Java_com_example_swift_SwiftModule__00024returnDate__(environment: UnsafeMutablePointer!, thisClass: jclass) -> jlong { + public func Java_com_example_swift_SwiftModule__00024returnDate__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> jlong { """ ] ) @@ -143,11 +143,11 @@ struct DateTests { [ """ @_cdecl("Java_com_example_swift_Date__00024init__D") - public func Java_com_example_swift_Date__00024init__D(environment: UnsafeMutablePointer!, thisClass: jclass, timeIntervalSince1970: jdouble) -> jlong { + public func Java_com_example_swift_Date__00024init__D(environment: JNIEnvironment!, thisClass: JNITypes.jclass, timeIntervalSince1970: jdouble) -> jlong { """, """ @_cdecl("Java_com_example_swift_Date__00024getTimeIntervalSince1970__J") - public func Java_com_example_swift_Date__00024getTimeIntervalSince1970__J(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) -> jdouble { + public func Java_com_example_swift_Date__00024getTimeIntervalSince1970__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong) -> jdouble { """, ] ) diff --git a/Tests/JExtractSwiftTests/IfConfigTests.swift b/Tests/JExtractSwiftTests/IfConfigTests.swift index 32545c3d7..77aa963ef 100644 --- a/Tests/JExtractSwiftTests/IfConfigTests.swift +++ b/Tests/JExtractSwiftTests/IfConfigTests.swift @@ -153,7 +153,7 @@ struct IfConfigTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_AppStore__00024init__J") - public func Java_com_example_swift_AppStore__00024init__J(environment: UnsafeMutablePointer!, thisClass: jclass, storeURL: jlong) -> jlong + public func Java_com_example_swift_AppStore__00024init__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, storeURL: jlong) -> jlong """ ] ) diff --git a/Tests/JExtractSwiftTests/JNI/JNIArrayTest.swift b/Tests/JExtractSwiftTests/JNI/JNIArrayTest.swift index 753b750c2..2a57a9d2a 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIArrayTest.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIArrayTest.swift @@ -48,7 +48,7 @@ struct JNIArrayTest { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024f___3B") - public func Java_com_example_swift_SwiftModule__00024f___3B(environment: UnsafeMutablePointer!, thisClass: jclass, array: jbyteArray?) -> jbyteArray? { + public func Java_com_example_swift_SwiftModule__00024f___3B(environment: JNIEnvironment!, thisClass: JNITypes.jclass, array: JNITypes.jbyteArray?) -> JNITypes.jbyteArray? { return SwiftModule.f(array: [UInt8](fromJNI: array, in: environment)).getJNILocalRefValue(in: environment) } """ @@ -86,7 +86,7 @@ struct JNIArrayTest { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024f___3B") - public func Java_com_example_swift_SwiftModule__00024f___3B(environment: UnsafeMutablePointer!, thisClass: jclass, array: jbyteArray?) -> jbyteArray? { + public func Java_com_example_swift_SwiftModule__00024f___3B(environment: JNIEnvironment!, thisClass: JNITypes.jclass, array: JNITypes.jbyteArray?) -> JNITypes.jbyteArray? { return SwiftModule.f(array: [UInt8](fromJNI: array, in: environment)).getJNILocalRefValue(in: environment) } """ @@ -124,7 +124,7 @@ struct JNIArrayTest { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024f___3J") - public func Java_com_example_swift_SwiftModule__00024f___3J(environment: UnsafeMutablePointer!, thisClass: jclass, array: jlongArray?) -> jlongArray? { + public func Java_com_example_swift_SwiftModule__00024f___3J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, array: JNITypes.jlongArray?) -> JNITypes.jlongArray? { return SwiftModule.f(array: [Int64](fromJNI: array, in: environment)).getJNILocalRefValue(in: environment) } """ @@ -171,7 +171,7 @@ struct JNIArrayTest { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024f___3J") - public func Java_com_example_swift_SwiftModule__00024f___3J(environment: UnsafeMutablePointer!, thisClass: jclass, array: jlongArray?) -> jlongArray? { + public func Java_com_example_swift_SwiftModule__00024f___3J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, array: JNITypes.jlongArray?) -> JNITypes.jlongArray? { return SwiftModule.f(array: [Int64](fromJNI: array, in: environment).map( { (pointer$) in assert(pointer$ != 0, "pointer$ memory address was null") let pointer$Bits$ = Int(pointer$) @@ -228,7 +228,7 @@ struct JNIArrayTest { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024f___3_3B") - public func Java_com_example_swift_SwiftModule__00024f___3_3B(environment: UnsafeMutablePointer!, thisClass: jclass, data: jobjectArray?) -> jobjectArray? { + public func Java_com_example_swift_SwiftModule__00024f___3_3B(environment: JNIEnvironment!, thisClass: JNITypes.jclass, data: JNITypes.jobjectArray?) -> JNITypes.jobjectArray? { return SwiftModule.f(data: [[UInt8]](fromJNI: data, in: environment)).getJNILocalRefValue(in: environment) } """ @@ -266,7 +266,7 @@ struct JNIArrayTest { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024f___3_3J") - public func Java_com_example_swift_SwiftModule__00024f___3_3J(environment: UnsafeMutablePointer!, thisClass: jclass, data: jobjectArray?) -> jobjectArray? { + public func Java_com_example_swift_SwiftModule__00024f___3_3J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, data: JNITypes.jobjectArray?) -> JNITypes.jobjectArray? { return SwiftModule.f(data: [[Int64]](fromJNI: data, in: environment)).getJNILocalRefValue(in: environment) } """ @@ -304,7 +304,7 @@ struct JNIArrayTest { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024f___3_3Ljava_lang_String_2") - public func Java_com_example_swift_SwiftModule__00024f___3_3Ljava_lang_String_2(environment: UnsafeMutablePointer!, thisClass: jclass, data: jobjectArray?) -> jobjectArray? { + public func Java_com_example_swift_SwiftModule__00024f___3_3Ljava_lang_String_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, data: JNITypes.jobjectArray?) -> JNITypes.jobjectArray? { return SwiftModule.f(data: [[String]](fromJNI: data, in: environment)).getJNILocalRefValue(in: environment) } """ @@ -349,12 +349,12 @@ struct JNIArrayTest { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024namedByteArrayTuple___3_3B_3_3B") - public func Java_com_example_swift_SwiftModule__00024namedByteArrayTuple___3_3B_3_3B(environment: UnsafeMutablePointer!, thisClass: jclass, result_0$: jobjectArray?, result_1$: jobjectArray?) { + public func Java_com_example_swift_SwiftModule__00024namedByteArrayTuple___3_3B_3_3B(environment: JNIEnvironment!, thisClass: JNITypes.jclass, result_0$: JNITypes.jobjectArray?, result_1$: JNITypes.jobjectArray?) { let tupleResult$ = SwiftModule.namedByteArrayTuple() let element_0_jni$ = tupleResult$.name.getJNILocalRefValue(in: environment) - environment.interface.SetObjectArrayElement(environment, result_0$, 0, element_0_jni$) + environment.swiftInterface.SetObjectArrayElement(environment, result_0$, 0, element_0_jni$) let element_1_jni$ = tupleResult$.another.getJNILocalRefValue(in: environment) - environment.interface.SetObjectArrayElement(environment, result_1$, 0, element_1_jni$) + environment.swiftInterface.SetObjectArrayElement(environment, result_1$, 0, element_1_jni$) return } """ diff --git a/Tests/JExtractSwiftTests/JNI/JNIAsyncTests.swift b/Tests/JExtractSwiftTests/JNI/JNIAsyncTests.swift index 825204af7..c4f5a3706 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIAsyncTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIAsyncTests.swift @@ -60,8 +60,8 @@ struct JNIAsyncTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024asyncVoid__Ljava_util_concurrent_CompletableFuture_2") - public func Java_com_example_swift_SwiftModule__00024asyncVoid__Ljava_util_concurrent_CompletableFuture_2(environment: UnsafeMutablePointer!, thisClass: jclass, result_future: jobject?) { - nonisolated(unsafe) let globalFuture = environment.interface.NewGlobalRef(environment, result_future) + public func Java_com_example_swift_SwiftModule__00024asyncVoid__Ljava_util_concurrent_CompletableFuture_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, result_future: JNITypes.jobject?) { + nonisolated(unsafe) let globalFuture = environment.swiftInterface.NewGlobalRef(environment, result_future) var task: Task? = nil #if swift(>=6.2) if #available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, *) { @@ -69,11 +69,11 @@ struct JNIAsyncTests { var environment = try! JavaVirtualMachine.shared().environment() defer { let deferEnvironment = try! JavaVirtualMachine.shared().environment() - deferEnvironment.interface.DeleteGlobalRef(deferEnvironment, globalFuture) + deferEnvironment.swiftInterface.DeleteGlobalRef(deferEnvironment, globalFuture) } await SwiftModule.asyncVoid() environment = try! JavaVirtualMachine.shared().environment() - _ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)]) + _ = environment.swiftInterface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [JNITypes.objectValue(nil)]) } } #endif @@ -82,11 +82,11 @@ struct JNIAsyncTests { var environment = try! JavaVirtualMachine.shared().environment() defer { let deferEnvironment = try! JavaVirtualMachine.shared().environment() - deferEnvironment.interface.DeleteGlobalRef(deferEnvironment, globalFuture) + deferEnvironment.swiftInterface.DeleteGlobalRef(deferEnvironment, globalFuture) } await SwiftModule.asyncVoid() environment = try! JavaVirtualMachine.shared().environment() - _ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)]) + _ = environment.swiftInterface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [JNITypes.objectValue(nil)]) } } } @@ -136,8 +136,8 @@ struct JNIAsyncTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024async__Ljava_util_concurrent_CompletableFuture_2") - public func Java_com_example_swift_SwiftModule__00024async__Ljava_util_concurrent_CompletableFuture_2(environment: UnsafeMutablePointer!, thisClass: jclass, result_future: jobject?) { - nonisolated(unsafe) let globalFuture = environment.interface.NewGlobalRef(environment, result_future) + public func Java_com_example_swift_SwiftModule__00024async__Ljava_util_concurrent_CompletableFuture_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, result_future: JNITypes.jobject?) { + nonisolated(unsafe) let globalFuture = environment.swiftInterface.NewGlobalRef(environment, result_future) var task: Task? = nil #if swift(>=6.2) if #available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, *) { @@ -145,17 +145,17 @@ struct JNIAsyncTests { var environment = try! JavaVirtualMachine.shared().environment() defer { let deferEnvironment = try! JavaVirtualMachine.shared().environment() - deferEnvironment.interface.DeleteGlobalRef(deferEnvironment, globalFuture) + deferEnvironment.swiftInterface.DeleteGlobalRef(deferEnvironment, globalFuture) } do { try await SwiftModule.async() environment = try! JavaVirtualMachine.shared().environment() - _ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)]) + _ = environment.swiftInterface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [JNITypes.objectValue(nil)]) } catch { let catchEnvironment = try! JavaVirtualMachine.shared().environment() - let exception = catchEnvironment.interface.NewObjectA(catchEnvironment, _JNIMethodIDCache.Exception.class, _JNIMethodIDCache.Exception.constructWithMessage, [String(describing: error).getJValue(in: catchEnvironment)]) - _ = catchEnvironment.interface.CallBooleanMethodA(catchEnvironment, globalFuture, _JNIMethodIDCache.CompletableFuture.completeExceptionally, [jvalue(l: exception)]) + let exception = catchEnvironment.swiftInterface.NewObjectA(catchEnvironment, _JNIMethodIDCache.Exception.class, _JNIMethodIDCache.Exception.constructWithMessage, [String(describing: error).getJValue(in: catchEnvironment)]) + _ = catchEnvironment.swiftInterface.CallBooleanMethodA(catchEnvironment, globalFuture, _JNIMethodIDCache.CompletableFuture.completeExceptionally, [JNITypes.objectValue(exception)]) } } } @@ -165,17 +165,17 @@ struct JNIAsyncTests { var environment = try! JavaVirtualMachine.shared().environment() defer { let deferEnvironment = try! JavaVirtualMachine.shared().environment() - deferEnvironment.interface.DeleteGlobalRef(deferEnvironment, globalFuture) + deferEnvironment.swiftInterface.DeleteGlobalRef(deferEnvironment, globalFuture) } do { try await SwiftModule.async() environment = try! JavaVirtualMachine.shared().environment() - _ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)]) + _ = environment.swiftInterface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [JNITypes.objectValue(nil)]) } catch { let catchEnvironment = try! JavaVirtualMachine.shared().environment() - let exception = catchEnvironment.interface.NewObjectA(catchEnvironment, _JNIMethodIDCache.Exception.class, _JNIMethodIDCache.Exception.constructWithMessage, [String(describing: error).getJValue(in: catchEnvironment)]) - _ = catchEnvironment.interface.CallBooleanMethodA(catchEnvironment, globalFuture, _JNIMethodIDCache.CompletableFuture.completeExceptionally, [jvalue(l: exception)]) + let exception = catchEnvironment.swiftInterface.NewObjectA(catchEnvironment, _JNIMethodIDCache.Exception.class, _JNIMethodIDCache.Exception.constructWithMessage, [String(describing: error).getJValue(in: catchEnvironment)]) + _ = catchEnvironment.swiftInterface.CallBooleanMethodA(catchEnvironment, globalFuture, _JNIMethodIDCache.CompletableFuture.completeExceptionally, [JNITypes.objectValue(exception)]) } } } @@ -226,8 +226,8 @@ struct JNIAsyncTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024async__JLjava_util_concurrent_CompletableFuture_2") - public func Java_com_example_swift_SwiftModule__00024async__JLjava_util_concurrent_CompletableFuture_2(environment: UnsafeMutablePointer!, thisClass: jclass, i: jlong, result_future: jobject?) { - nonisolated(unsafe) let globalFuture = environment.interface.NewGlobalRef(environment, result_future) + public func Java_com_example_swift_SwiftModule__00024async__JLjava_util_concurrent_CompletableFuture_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, i: jlong, result_future: JNITypes.jobject?) { + nonisolated(unsafe) let globalFuture = environment.swiftInterface.NewGlobalRef(environment, result_future) var task: Task? = nil #if swift(>=6.2) if #available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, *) { @@ -235,12 +235,12 @@ struct JNIAsyncTests { var environment = try! JavaVirtualMachine.shared().environment() defer { let deferEnvironment = try! JavaVirtualMachine.shared().environment() - deferEnvironment.interface.DeleteGlobalRef(deferEnvironment, globalFuture) + deferEnvironment.swiftInterface.DeleteGlobalRef(deferEnvironment, globalFuture) } let swiftResult$ = await SwiftModule.async(i: Int64(fromJNI: i, in: environment)) environment = try! JavaVirtualMachine.shared().environment() let boxedResult$ = SwiftJavaRuntimeSupport._JNIBoxedConversions.box(swiftResult$.getJNILocalRefValue(in: environment), in: environment) - _ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)]) + _ = environment.swiftInterface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [JNITypes.objectValue(boxedResult$)]) } } #endif // end of swift(>=6.2) @@ -249,12 +249,12 @@ struct JNIAsyncTests { var environment = try! JavaVirtualMachine.shared().environment() defer { let deferEnvironment = try! JavaVirtualMachine.shared().environment() - deferEnvironment.interface.DeleteGlobalRef(deferEnvironment, globalFuture) + deferEnvironment.swiftInterface.DeleteGlobalRef(deferEnvironment, globalFuture) } let swiftResult$ = await SwiftModule.async(i: Int64(fromJNI: i, in: environment)) environment = try! JavaVirtualMachine.shared().environment() let boxedResult$ = SwiftJavaRuntimeSupport._JNIBoxedConversions.box(swiftResult$.getJNILocalRefValue(in: environment), in: environment) - _ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)]) + _ = environment.swiftInterface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [JNITypes.objectValue(boxedResult$)]) } } return @@ -313,14 +313,14 @@ struct JNIAsyncTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024async__JLjava_util_concurrent_CompletableFuture_2") - public func Java_com_example_swift_SwiftModule__00024async__JLjava_util_concurrent_CompletableFuture_2(environment: UnsafeMutablePointer!, thisClass: jclass, c: jlong, result_future: jobject?) { + public func Java_com_example_swift_SwiftModule__00024async__JLjava_util_concurrent_CompletableFuture_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, c: jlong, result_future: JNITypes.jobject?) { assert(c != 0, "c memory address was null") let cBits$ = Int(Int64(fromJNI: c, in: environment)) let c$ = UnsafeMutablePointer(bitPattern: cBits$) guard let c$ else { fatalError("c memory address was null in call to \\(#function)!") } - nonisolated(unsafe) let globalFuture = environment.interface.NewGlobalRef(environment, result_future) + nonisolated(unsafe) let globalFuture = environment.swiftInterface.NewGlobalRef(environment, result_future) var task: Task? = nil #if swift(>=6.2) if #available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, *) { @@ -328,7 +328,7 @@ struct JNIAsyncTests { var environment = try! JavaVirtualMachine.shared().environment() defer { let deferEnvironment = try! JavaVirtualMachine.shared().environment() - deferEnvironment.interface.DeleteGlobalRef(deferEnvironment, globalFuture) + deferEnvironment.swiftInterface.DeleteGlobalRef(deferEnvironment, globalFuture) } let swiftResult$ = await SwiftModule.async(c: c$.pointee) environment = try! JavaVirtualMachine.shared().environment() @@ -336,7 +336,7 @@ struct JNIAsyncTests { result$.initialize(to: swiftResult$) let resultBits$ = Int64(Int(bitPattern: result$)) let boxedResult$ = SwiftJavaRuntimeSupport._JNIBoxedConversions.box(resultBits$.getJNILocalRefValue(in: environment), in: environment) - _ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)]) + _ = environment.swiftInterface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [JNITypes.objectValue(boxedResult$)]) } } #endif @@ -345,7 +345,7 @@ struct JNIAsyncTests { var environment = try! JavaVirtualMachine.shared().environment() defer { let deferEnvironment = try! JavaVirtualMachine.shared().environment() - deferEnvironment.interface.DeleteGlobalRef(deferEnvironment, globalFuture) + deferEnvironment.swiftInterface.DeleteGlobalRef(deferEnvironment, globalFuture) } let swiftResult$ = await SwiftModule.async(c: c$.pointee) environment = try! JavaVirtualMachine.shared().environment() @@ -353,7 +353,7 @@ struct JNIAsyncTests { result$.initialize(to: swiftResult$) let resultBits$ = Int64(Int(bitPattern: result$)) let boxedResult$ = SwiftJavaRuntimeSupport._JNIBoxedConversions.box(resultBits$.getJNILocalRefValue(in: environment), in: environment) - _ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)]) + _ = environment.swiftInterface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [JNITypes.objectValue(boxedResult$)]) } } return @@ -402,17 +402,17 @@ struct JNIAsyncTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024async__Ljava_lang_String_2Ljava_util_concurrent_CompletableFuture_2") - public func Java_com_example_swift_SwiftModule__00024async__Ljava_lang_String_2Ljava_util_concurrent_CompletableFuture_2(environment: UnsafeMutablePointer!, thisClass: jclass, s: jstring?, result_future: jobject?) { - nonisolated(unsafe) let s = environment.interface.NewGlobalRef(environment, s) - nonisolated(unsafe) let globalFuture = environment.interface.NewGlobalRef(environment, result_future) + public func Java_com_example_swift_SwiftModule__00024async__Ljava_lang_String_2Ljava_util_concurrent_CompletableFuture_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, s: JNITypes.jstring?, result_future: JNITypes.jobject?) { + nonisolated(unsafe) let s = environment.swiftInterface.NewGlobalRef(environment, s) + nonisolated(unsafe) let globalFuture = environment.swiftInterface.NewGlobalRef(environment, result_future) ... defer { let deferEnvironment = try! JavaVirtualMachine.shared().environment() - deferEnvironment.interface.DeleteGlobalRef(deferEnvironment, globalFuture) - deferEnvironment.interface.DeleteGlobalRef(deferEnvironment, s) + deferEnvironment.swiftInterface.DeleteGlobalRef(deferEnvironment, globalFuture) + deferEnvironment.swiftInterface.DeleteGlobalRef(deferEnvironment, s) } ... - _ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: swiftResult$.getJNILocalRefValue(in: environment))]) + _ = environment.swiftInterface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [JNITypes.objectValue(swiftResult$.getJNILocalRefValue(in: environment))]) ... } """ @@ -471,11 +471,11 @@ struct JNIAsyncTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024async__JLorg_swift_swiftkit_core_SimpleCompletableFuture_2") - public func Java_com_example_swift_SwiftModule__00024async__JLorg_swift_swiftkit_core_SimpleCompletableFuture_2(environment: UnsafeMutablePointer!, thisClass: jclass, c: jlong, result_future: jobject?) { + public func Java_com_example_swift_SwiftModule__00024async__JLorg_swift_swiftkit_core_SimpleCompletableFuture_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, c: jlong, result_future: JNITypes.jobject?) { ... var task: Task? = nil ... - _ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.SimpleCompletableFuture.complete, [jvalue(l: boxedResult$)]) + _ = environment.swiftInterface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.SimpleCompletableFuture.complete, [JNITypes.objectValue(boxedResult$)]) ... } """ @@ -521,11 +521,11 @@ struct JNIAsyncTests { let swiftResult$ = await SwiftModule.\(functionName)() environment = try! JavaVirtualMachine.shared().environment() ... - _ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)]) + _ = environment.swiftInterface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [JNITypes.objectValue(nil)]) """ ], notExpectedChunks: [ - "[jvalue(l: )]" + "[JNITypes.objectValue()]" ] ) } diff --git a/Tests/JExtractSwiftTests/JNI/JNIClassTests.swift b/Tests/JExtractSwiftTests/JNI/JNIClassTests.swift index 366d0598b..270efae74 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIClassTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIClassTests.swift @@ -137,7 +137,7 @@ struct JNIClassTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyClass__00024method__") - public func Java_com_example_swift_MyClass__00024method__(environment: UnsafeMutablePointer!, thisClass: jclass) { + public func Java_com_example_swift_MyClass__00024method__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) { MyClass.method() } """ @@ -180,7 +180,7 @@ struct JNIClassTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyClass__00024classMethod__") - public func Java_com_example_swift_MyClass__00024classMethod__(environment: UnsafeMutablePointer!, thisClass: jclass) -> jlong { + public func Java_com_example_swift_MyClass__00024classMethod__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> jlong { return MyClass.classMethod().getJNILocalRefValue(in: environment) } """ @@ -223,7 +223,7 @@ struct JNIClassTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyClass__00024getClassVariable__") - public func Java_com_example_swift_MyClass__00024getClassVariable__(environment: UnsafeMutablePointer!, thisClass: jclass) -> jlong { + public func Java_com_example_swift_MyClass__00024getClassVariable__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> jlong { return MyClass.classVariable.getJNILocalRefValue(in: environment) } """ @@ -280,7 +280,7 @@ struct JNIClassTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyClass__00024init__JJ") - public func Java_com_example_swift_MyClass__00024init__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, x: jlong, y: jlong) -> jlong { + public func Java_com_example_swift_MyClass__00024init__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, x: jlong, y: jlong) -> jlong { let result$ = UnsafeMutablePointer.allocate(capacity: 1) result$.initialize(to: MyClass.init(x: Int64(fromJNI: x, in: environment), y: Int64(fromJNI: y, in: environment))) let resultBits$ = Int64(Int(bitPattern: result$)) @@ -289,7 +289,7 @@ struct JNIClassTests { """, """ @_cdecl("Java_com_example_swift_MyClass__00024init__") - public func Java_com_example_swift_MyClass__00024init__(environment: UnsafeMutablePointer!, thisClass: jclass) -> jlong { + public func Java_com_example_swift_MyClass__00024init__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> jlong { let result$ = UnsafeMutablePointer.allocate(capacity: 1) result$.initialize(to: MyClass.init()) let resultBits$ = Int64(Int(bitPattern: result$)) @@ -335,7 +335,7 @@ struct JNIClassTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyClass__00024doSomething__JJ") - public func Java_com_example_swift_MyClass__00024doSomething__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, x: jlong, selfPointer: jlong) { + public func Java_com_example_swift_MyClass__00024doSomething__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, x: jlong, selfPointer: jlong) { assert(selfPointer != 0, "selfPointer memory address was null") let selfPointerBits$ = Int(Int64(fromJNI: selfPointer, in: environment)) let selfPointer$ = UnsafeMutablePointer(bitPattern: selfPointerBits$) @@ -384,7 +384,7 @@ struct JNIClassTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyClass__00024copy__J") - public func Java_com_example_swift_MyClass__00024copy__J(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) -> jlong { + public func Java_com_example_swift_MyClass__00024copy__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong) -> jlong { assert(selfPointer != 0, "selfPointer memory address was null") let selfPointerBits$ = Int(Int64(fromJNI: selfPointer, in: environment)) let selfPointer$ = UnsafeMutablePointer(bitPattern: selfPointerBits$) @@ -436,7 +436,7 @@ struct JNIClassTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyClass__00024isEqual__JJ") - public func Java_com_example_swift_MyClass__00024isEqual__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, other: jlong, selfPointer: jlong) -> jboolean { + public func Java_com_example_swift_MyClass__00024isEqual__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, other: jlong, selfPointer: jlong) -> jboolean { assert(other != 0, "other memory address was null") let otherBits$ = Int(Int64(fromJNI: other, in: environment)) let other$ = UnsafeMutablePointer(bitPattern: otherBits$) diff --git a/Tests/JExtractSwiftTests/JNI/JNIClosureTests.swift b/Tests/JExtractSwiftTests/JNI/JNIClosureTests.swift index aa5f1fa6e..ff5571b23 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIClosureTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIClosureTests.swift @@ -638,13 +638,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024emptyClosure__Ljava_lang_Runnable_2") - public func Java_com_example_swift_SwiftModule__00024emptyClosure__Ljava_lang_Runnable_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024emptyClosure__Ljava_lang_Runnable_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.emptyClosure(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "run", "()V")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [] - environment.interface.CallVoidMethodA(environment, closure, methodID$, arguments$) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "run", "()V")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [] + environment.swiftInterface.CallVoidMethodA(environment, closure, methodID$, arguments$) } ) } @@ -663,13 +663,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureBoolSupplier__Ljava_util_function_BooleanSupplier_2") - public func Java_com_example_swift_SwiftModule__00024closureBoolSupplier__Ljava_util_function_BooleanSupplier_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureBoolSupplier__Ljava_util_function_BooleanSupplier_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureBoolSupplier(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "getAsBoolean", "()Z")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [] - return Bool(fromJNI: environment.interface.CallBooleanMethodA(environment, closure, methodID$, arguments$), in: environment) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "getAsBoolean", "()Z")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [] + return Bool(fromJNI: environment.swiftInterface.CallBooleanMethodA(environment, closure, methodID$, arguments$), in: environment) } ) } @@ -688,13 +688,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureIntSupplier__Ljava_util_function_IntSupplier_2") - public func Java_com_example_swift_SwiftModule__00024closureIntSupplier__Ljava_util_function_IntSupplier_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureIntSupplier__Ljava_util_function_IntSupplier_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureIntSupplier(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "getAsInt", "()I")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [] - return Int32(fromJNI: environment.interface.CallIntMethodA(environment, closure, methodID$, arguments$), in: environment) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "getAsInt", "()I")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [] + return Int32(fromJNI: environment.swiftInterface.CallIntMethodA(environment, closure, methodID$, arguments$), in: environment) } ) } @@ -713,13 +713,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureLongSupplier__Ljava_util_function_LongSupplier_2") - public func Java_com_example_swift_SwiftModule__00024closureLongSupplier__Ljava_util_function_LongSupplier_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureLongSupplier__Ljava_util_function_LongSupplier_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureLongSupplier(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "getAsLong", "()J")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [] - return Int64(fromJNI: environment.interface.CallLongMethodA(environment, closure, methodID$, arguments$), in: environment) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "getAsLong", "()J")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [] + return Int64(fromJNI: environment.swiftInterface.CallLongMethodA(environment, closure, methodID$, arguments$), in: environment) } ) } @@ -738,13 +738,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureDoubleSupplier__Ljava_util_function_DoubleSupplier_2") - public func Java_com_example_swift_SwiftModule__00024closureDoubleSupplier__Ljava_util_function_DoubleSupplier_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureDoubleSupplier__Ljava_util_function_DoubleSupplier_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureDoubleSupplier(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "getAsDouble", "()D")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [] - return Double(fromJNI: environment.interface.CallDoubleMethodA(environment, closure, methodID$, arguments$), in: environment) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "getAsDouble", "()D")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [] + return Double(fromJNI: environment.swiftInterface.CallDoubleMethodA(environment, closure, methodID$, arguments$), in: environment) } ) } @@ -763,13 +763,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureIntConsumer__Ljava_util_function_IntConsumer_2") - public func Java_com_example_swift_SwiftModule__00024closureIntConsumer__Ljava_util_function_IntConsumer_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureIntConsumer__Ljava_util_function_IntConsumer_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureIntConsumer(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "accept", "(I)V")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [_0.getJValue(in: environment)] - environment.interface.CallVoidMethodA(environment, closure, methodID$, arguments$) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "accept", "(I)V")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [_0.getJValue(in: environment)] + environment.swiftInterface.CallVoidMethodA(environment, closure, methodID$, arguments$) } ) } @@ -788,13 +788,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureLongConsumer__Ljava_util_function_LongConsumer_2") - public func Java_com_example_swift_SwiftModule__00024closureLongConsumer__Ljava_util_function_LongConsumer_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureLongConsumer__Ljava_util_function_LongConsumer_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureLongConsumer(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "accept", "(J)V")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [_0.getJValue(in: environment)] - environment.interface.CallVoidMethodA(environment, closure, methodID$, arguments$) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "accept", "(J)V")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [_0.getJValue(in: environment)] + environment.swiftInterface.CallVoidMethodA(environment, closure, methodID$, arguments$) } ) } @@ -813,13 +813,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureDoubleConsumer__Ljava_util_function_DoubleConsumer_2") - public func Java_com_example_swift_SwiftModule__00024closureDoubleConsumer__Ljava_util_function_DoubleConsumer_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureDoubleConsumer__Ljava_util_function_DoubleConsumer_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureDoubleConsumer(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "accept", "(D)V")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [_0.getJValue(in: environment)] - environment.interface.CallVoidMethodA(environment, closure, methodID$, arguments$) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "accept", "(D)V")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [_0.getJValue(in: environment)] + environment.swiftInterface.CallVoidMethodA(environment, closure, methodID$, arguments$) } ) } @@ -838,13 +838,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureIntPredicate__Ljava_util_function_IntPredicate_2") - public func Java_com_example_swift_SwiftModule__00024closureIntPredicate__Ljava_util_function_IntPredicate_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureIntPredicate__Ljava_util_function_IntPredicate_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureIntPredicate(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "test", "(I)Z")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [_0.getJValue(in: environment)] - return Bool(fromJNI: environment.interface.CallBooleanMethodA(environment, closure, methodID$, arguments$), in: environment) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "test", "(I)Z")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [_0.getJValue(in: environment)] + return Bool(fromJNI: environment.swiftInterface.CallBooleanMethodA(environment, closure, methodID$, arguments$), in: environment) } ) } @@ -863,13 +863,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureLongPredicate__Ljava_util_function_LongPredicate_2") - public func Java_com_example_swift_SwiftModule__00024closureLongPredicate__Ljava_util_function_LongPredicate_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureLongPredicate__Ljava_util_function_LongPredicate_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureLongPredicate(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "test", "(J)Z")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [_0.getJValue(in: environment)] - return Bool(fromJNI: environment.interface.CallBooleanMethodA(environment, closure, methodID$, arguments$), in: environment) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "test", "(J)Z")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [_0.getJValue(in: environment)] + return Bool(fromJNI: environment.swiftInterface.CallBooleanMethodA(environment, closure, methodID$, arguments$), in: environment) } ) } @@ -888,13 +888,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureDoublePredicate__Ljava_util_function_DoublePredicate_2") - public func Java_com_example_swift_SwiftModule__00024closureDoublePredicate__Ljava_util_function_DoublePredicate_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureDoublePredicate__Ljava_util_function_DoublePredicate_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureDoublePredicate(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "test", "(D)Z")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [_0.getJValue(in: environment)] - return Bool(fromJNI: environment.interface.CallBooleanMethodA(environment, closure, methodID$, arguments$), in: environment) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "test", "(D)Z")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [_0.getJValue(in: environment)] + return Bool(fromJNI: environment.swiftInterface.CallBooleanMethodA(environment, closure, methodID$, arguments$), in: environment) } ) } @@ -913,13 +913,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureIntUnaryOperator__Ljava_util_function_IntUnaryOperator_2") - public func Java_com_example_swift_SwiftModule__00024closureIntUnaryOperator__Ljava_util_function_IntUnaryOperator_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureIntUnaryOperator__Ljava_util_function_IntUnaryOperator_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureIntUnaryOperator(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "applyAsInt", "(I)I")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [_0.getJValue(in: environment)] - return Int32(fromJNI: environment.interface.CallIntMethodA(environment, closure, methodID$, arguments$), in: environment) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "applyAsInt", "(I)I")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [_0.getJValue(in: environment)] + return Int32(fromJNI: environment.swiftInterface.CallIntMethodA(environment, closure, methodID$, arguments$), in: environment) } ) } @@ -938,13 +938,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureLongUnaryOperator__Ljava_util_function_LongUnaryOperator_2") - public func Java_com_example_swift_SwiftModule__00024closureLongUnaryOperator__Ljava_util_function_LongUnaryOperator_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureLongUnaryOperator__Ljava_util_function_LongUnaryOperator_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureLongUnaryOperator(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "applyAsLong", "(J)J")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [_0.getJValue(in: environment)] - return Int64(fromJNI: environment.interface.CallLongMethodA(environment, closure, methodID$, arguments$), in: environment) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "applyAsLong", "(J)J")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [_0.getJValue(in: environment)] + return Int64(fromJNI: environment.swiftInterface.CallLongMethodA(environment, closure, methodID$, arguments$), in: environment) } ) } @@ -963,13 +963,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureDoubleToIntFunction__Ljava_util_function_DoubleToIntFunction_2") - public func Java_com_example_swift_SwiftModule__00024closureDoubleToIntFunction__Ljava_util_function_DoubleToIntFunction_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureDoubleToIntFunction__Ljava_util_function_DoubleToIntFunction_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureDoubleToIntFunction(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "applyAsInt", "(D)I")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [_0.getJValue(in: environment)] - return Int32(fromJNI: environment.interface.CallIntMethodA(environment, closure, methodID$, arguments$), in: environment) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "applyAsInt", "(D)I")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [_0.getJValue(in: environment)] + return Int32(fromJNI: environment.swiftInterface.CallIntMethodA(environment, closure, methodID$, arguments$), in: environment) } ) } @@ -988,13 +988,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureLongToIntFunction__Ljava_util_function_LongToIntFunction_2") - public func Java_com_example_swift_SwiftModule__00024closureLongToIntFunction__Ljava_util_function_LongToIntFunction_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureLongToIntFunction__Ljava_util_function_LongToIntFunction_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureLongToIntFunction(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "applyAsInt", "(J)I")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [_0.getJValue(in: environment)] - return Int32(fromJNI: environment.interface.CallIntMethodA(environment, closure, methodID$, arguments$), in: environment) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "applyAsInt", "(J)I")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [_0.getJValue(in: environment)] + return Int32(fromJNI: environment.swiftInterface.CallIntMethodA(environment, closure, methodID$, arguments$), in: environment) } ) } @@ -1013,13 +1013,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureDoubleToLongFunction__Ljava_util_function_DoubleToLongFunction_2") - public func Java_com_example_swift_SwiftModule__00024closureDoubleToLongFunction__Ljava_util_function_DoubleToLongFunction_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureDoubleToLongFunction__Ljava_util_function_DoubleToLongFunction_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureDoubleToLongFunction(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "applyAsLong", "(D)J")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [_0.getJValue(in: environment)] - return Int64(fromJNI: environment.interface.CallLongMethodA(environment, closure, methodID$, arguments$), in: environment) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "applyAsLong", "(D)J")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [_0.getJValue(in: environment)] + return Int64(fromJNI: environment.swiftInterface.CallLongMethodA(environment, closure, methodID$, arguments$), in: environment) } ) } @@ -1038,13 +1038,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureIntToLongFunction__Ljava_util_function_IntToLongFunction_2") - public func Java_com_example_swift_SwiftModule__00024closureIntToLongFunction__Ljava_util_function_IntToLongFunction_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureIntToLongFunction__Ljava_util_function_IntToLongFunction_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureIntToLongFunction(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "applyAsLong", "(I)J")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [_0.getJValue(in: environment)] - return Int64(fromJNI: environment.interface.CallLongMethodA(environment, closure, methodID$, arguments$), in: environment) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "applyAsLong", "(I)J")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [_0.getJValue(in: environment)] + return Int64(fromJNI: environment.swiftInterface.CallLongMethodA(environment, closure, methodID$, arguments$), in: environment) } ) } @@ -1114,13 +1114,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureDoubleUnaryOperator__Ljava_util_function_DoubleUnaryOperator_2") - public func Java_com_example_swift_SwiftModule__00024closureDoubleUnaryOperator__Ljava_util_function_DoubleUnaryOperator_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureDoubleUnaryOperator__Ljava_util_function_DoubleUnaryOperator_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureDoubleUnaryOperator(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "applyAsDouble", "(D)D")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [_0.getJValue(in: environment)] - return Double(fromJNI: environment.interface.CallDoubleMethodA(environment, closure, methodID$, arguments$), in: environment) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "applyAsDouble", "(D)D")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [_0.getJValue(in: environment)] + return Double(fromJNI: environment.swiftInterface.CallDoubleMethodA(environment, closure, methodID$, arguments$), in: environment) } ) } @@ -1139,13 +1139,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureIntBinaryOperator__Ljava_util_function_IntBinaryOperator_2") - public func Java_com_example_swift_SwiftModule__00024closureIntBinaryOperator__Ljava_util_function_IntBinaryOperator_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureIntBinaryOperator__Ljava_util_function_IntBinaryOperator_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureIntBinaryOperator(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "applyAsInt", "(II)I")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [_0.getJValue(in: environment), _1.getJValue(in: environment)] - return Int32(fromJNI: environment.interface.CallIntMethodA(environment, closure, methodID$, arguments$), in: environment) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "applyAsInt", "(II)I")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [_0.getJValue(in: environment), _1.getJValue(in: environment)] + return Int32(fromJNI: environment.swiftInterface.CallIntMethodA(environment, closure, methodID$, arguments$), in: environment) } ) } @@ -1164,13 +1164,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureLongBinaryOperator__Ljava_util_function_LongBinaryOperator_2") - public func Java_com_example_swift_SwiftModule__00024closureLongBinaryOperator__Ljava_util_function_LongBinaryOperator_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureLongBinaryOperator__Ljava_util_function_LongBinaryOperator_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureLongBinaryOperator(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "applyAsLong", "(JJ)J")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [_0.getJValue(in: environment), _1.getJValue(in: environment)] - return Int64(fromJNI: environment.interface.CallLongMethodA(environment, closure, methodID$, arguments$), in: environment) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "applyAsLong", "(JJ)J")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [_0.getJValue(in: environment), _1.getJValue(in: environment)] + return Int64(fromJNI: environment.swiftInterface.CallLongMethodA(environment, closure, methodID$, arguments$), in: environment) } ) } @@ -1189,13 +1189,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureDoubleBinaryOperator__Ljava_util_function_DoubleBinaryOperator_2") - public func Java_com_example_swift_SwiftModule__00024closureDoubleBinaryOperator__Ljava_util_function_DoubleBinaryOperator_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureDoubleBinaryOperator__Ljava_util_function_DoubleBinaryOperator_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureDoubleBinaryOperator(closure: { - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "applyAsDouble", "(DD)D")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [_0.getJValue(in: environment), _1.getJValue(in: environment)] - return Double(fromJNI: environment.interface.CallDoubleMethodA(environment, closure, methodID$, arguments$), in: environment) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "applyAsDouble", "(DD)D")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [_0.getJValue(in: environment), _1.getJValue(in: environment)] + return Double(fromJNI: environment.swiftInterface.CallDoubleMethodA(environment, closure, methodID$, arguments$), in: environment) } ) } @@ -1248,13 +1248,13 @@ struct JNIClosureTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024closureWithArgumentsAndReturn__Lcom_example_swift_SwiftModule_00024closureWithArgumentsAndReturn_00024closure_2") - public func Java_com_example_swift_SwiftModule__00024closureWithArgumentsAndReturn__Lcom_example_swift_SwiftModule_00024closureWithArgumentsAndReturn_00024closure_2(environment: UnsafeMutablePointer!, thisClass: jclass, closure: jobject?) { + public func Java_com_example_swift_SwiftModule__00024closureWithArgumentsAndReturn__Lcom_example_swift_SwiftModule_00024closureWithArgumentsAndReturn_00024closure_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, closure: JNITypes.jobject?) { SwiftModule.closureWithArgumentsAndReturn(closure: { _0, _1 in - let class$ = environment.interface.GetObjectClass(environment, closure) - let methodID$ = environment.interface.GetMethodID(environment, class$, "apply", "(JZ)J")! - environment.interface.DeleteLocalRef(environment, class$) - let arguments$: [jvalue] = [_0.getJValue(in: environment), _1.getJValue(in: environment)] - return Int64(fromJNI: environment.interface.CallLongMethodA(environment, closure, methodID$, arguments$), in: environment) + let class$ = environment.swiftInterface.GetObjectClass(environment, closure) + let methodID$ = environment.swiftInterface.GetMethodID(environment, class$, "apply", "(JZ)J")! + environment.swiftInterface.DeleteLocalRef(environment, class$) + let arguments$: [JNITypes.jvalue] = [_0.getJValue(in: environment), _1.getJValue(in: environment)] + return Int64(fromJNI: environment.swiftInterface.CallLongMethodA(environment, closure, methodID$, arguments$), in: environment) } ) } diff --git a/Tests/JExtractSwiftTests/JNI/JNIDictionaryTest.swift b/Tests/JExtractSwiftTests/JNI/JNIDictionaryTest.swift index d595d8c0b..b5230712e 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIDictionaryTest.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIDictionaryTest.swift @@ -48,7 +48,7 @@ struct JNIDictionaryTest { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024f__") - public func Java_com_example_swift_SwiftModule__00024f__(environment: UnsafeMutablePointer!, thisClass: jclass) -> jlong { + public func Java_com_example_swift_SwiftModule__00024f__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> jlong { return SwiftModule.f().dictionaryGetJNIValue(in: environment, keyBridge: JavaBoxableBridge.self, valueBridge: JavaBoxableBridge.self) } """ @@ -86,7 +86,7 @@ struct JNIDictionaryTest { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024f__J") - public func Java_com_example_swift_SwiftModule__00024f__J(environment: UnsafeMutablePointer!, thisClass: jclass, dict: jlong) { + public func Java_com_example_swift_SwiftModule__00024f__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, dict: jlong) { SwiftModule.f(dict: [String: Int64](fromJNI: dict, in: environment, keyBridge: JavaBoxableBridge.self, valueBridge: JavaBoxableBridge.self)) } """ @@ -124,7 +124,7 @@ struct JNIDictionaryTest { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024f__J") - public func Java_com_example_swift_SwiftModule__00024f__J(environment: UnsafeMutablePointer!, thisClass: jclass, dict: jlong) -> jlong { + public func Java_com_example_swift_SwiftModule__00024f__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, dict: jlong) -> jlong { return SwiftModule.f(dict: [String: Int64](fromJNI: dict, in: environment, keyBridge: JavaBoxableBridge.self, valueBridge: JavaBoxableBridge.self)).dictionaryGetJNIValue(in: environment, keyBridge: JavaBoxableBridge.self, valueBridge: JavaBoxableBridge.self) } """ @@ -162,7 +162,7 @@ struct JNIDictionaryTest { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024f__J") - public func Java_com_example_swift_SwiftModule__00024f__J(environment: UnsafeMutablePointer!, thisClass: jclass, dict: jlong) -> jlong { + public func Java_com_example_swift_SwiftModule__00024f__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, dict: jlong) -> jlong { return SwiftModule.f(dict: [String: Int64](fromJNI: dict, in: environment, keyBridge: JavaBoxableBridge.self, valueBridge: JavaBoxableBridge.self)).dictionaryGetJNIValue(in: environment, keyBridge: JavaBoxableBridge.self, valueBridge: JavaBoxableBridge.self) } """ @@ -274,7 +274,7 @@ struct JNIDictionaryTest { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024f__JJ") - public func Java_com_example_swift_SwiftModule__00024f__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, a: jlong, b: jlong) { + public func Java_com_example_swift_SwiftModule__00024f__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, a: jlong, b: jlong) { SwiftModule.f(a: [String: Int64](fromJNI: a, in: environment, keyBridge: JavaBoxableBridge.self, valueBridge: JavaBoxableBridge.self), b: [String: Bool](fromJNI: b, in: environment, keyBridge: JavaBoxableBridge.self, valueBridge: JavaBoxableBridge.self)) } """ @@ -315,7 +315,7 @@ struct JNIDictionaryTest { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024f__JLjava_lang_String_2J") - public func Java_com_example_swift_SwiftModule__00024f__JLjava_lang_String_2J(environment: UnsafeMutablePointer!, thisClass: jclass, dict: jlong, key: jstring?, value: jlong) -> jlong { + public func Java_com_example_swift_SwiftModule__00024f__JLjava_lang_String_2J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, dict: jlong, key: JNITypes.jstring?, value: jlong) -> jlong { return SwiftModule.f(dict: [String: Int64](fromJNI: dict, in: environment, keyBridge: JavaBoxableBridge.self, valueBridge: JavaBoxableBridge.self), key: String(fromJNI: key, in: environment), value: Int64(fromJNI: value, in: environment)).dictionaryGetJNIValue(in: environment, keyBridge: JavaBoxableBridge.self, valueBridge: JavaBoxableBridge.self) } """ diff --git a/Tests/JExtractSwiftTests/JNI/JNIDistributedActorTests.swift b/Tests/JExtractSwiftTests/JNI/JNIDistributedActorTests.swift index 2ec0805b5..0b697541d 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIDistributedActorTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIDistributedActorTests.swift @@ -73,8 +73,8 @@ struct JNIDistributedActorTests { """ catch { let catchEnvironment = try! JavaVirtualMachine.shared().environment() - let exception = catchEnvironment.interface.NewObjectA(catchEnvironment, _JNIMethodIDCache.Exception.class, _JNIMethodIDCache.Exception.constructWithMessage, [String(describing: error).getJValue(in: catchEnvironment)]) - _ = catchEnvironment.interface.CallBooleanMethodA(catchEnvironment, globalFuture, _JNIMethodIDCache.CompletableFuture.completeExceptionally, [jvalue(l: exception)]) + let exception = catchEnvironment.swiftInterface.NewObjectA(catchEnvironment, _JNIMethodIDCache.Exception.class, _JNIMethodIDCache.Exception.constructWithMessage, [String(describing: error).getJValue(in: catchEnvironment)]) + _ = catchEnvironment.swiftInterface.CallBooleanMethodA(catchEnvironment, globalFuture, _JNIMethodIDCache.CompletableFuture.completeExceptionally, [JNITypes.objectValue(exception)]) } """, ] diff --git a/Tests/JExtractSwiftTests/JNI/JNIEnumTests.swift b/Tests/JExtractSwiftTests/JNI/JNIEnumTests.swift index 9bb75bb74..24b4d06a1 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIEnumTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIEnumTests.swift @@ -201,7 +201,7 @@ struct JNIEnumTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyEnum__00024first__") - public func Java_com_example_swift_MyEnum__00024first__(environment: UnsafeMutablePointer!, thisClass: jclass) -> jlong { + public func Java_com_example_swift_MyEnum__00024first__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> jlong { let result$ = UnsafeMutablePointer.allocate(capacity: 1) result$.initialize(to: MyEnum.first) let resultBits$ = Int64(Int(bitPattern: result$)) @@ -210,7 +210,7 @@ struct JNIEnumTests { """, """ @_cdecl("Java_com_example_swift_MyEnum__00024second__Ljava_lang_String_2") - public func Java_com_example_swift_MyEnum__00024second__Ljava_lang_String_2(environment: UnsafeMutablePointer!, thisClass: jclass, arg0: jstring?) -> jlong { + public func Java_com_example_swift_MyEnum__00024second__Ljava_lang_String_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, arg0: JNITypes.jstring?) -> jlong { let result$ = UnsafeMutablePointer.allocate(capacity: 1) result$.initialize(to: MyEnum.second(String(fromJNI: arg0, in: environment))) let resultBits$ = Int64(Int(bitPattern: result$)) @@ -219,7 +219,7 @@ struct JNIEnumTests { """, """ @_cdecl("Java_com_example_swift_MyEnum__00024third__JIJ") - public func Java_com_example_swift_MyEnum__00024third__JIJ(environment: UnsafeMutablePointer!, thisClass: jclass, x: jlong, y: jint, arg2: jlong) -> jlong { + public func Java_com_example_swift_MyEnum__00024third__JIJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, x: jlong, y: jint, arg2: jlong) -> jlong { assert(arg2 != 0, "arg2 memory address was null") let arg2Bits$ = Int(Int64(fromJNI: arg2, in: environment)) let arg2$ = UnsafeMutablePointer(bitPattern: arg2Bits$) diff --git a/Tests/JExtractSwiftTests/JNI/JNIGenericCombinationTests.swift b/Tests/JExtractSwiftTests/JNI/JNIGenericCombinationTests.swift index 45b4cb2ec..d61b63be2 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIGenericCombinationTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIGenericCombinationTests.swift @@ -79,23 +79,23 @@ struct JNIGenericCombinationTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024makeStringIDOptional__Ljava_lang_String_2_3BLorg_swift_swiftkit_core__1OutSwiftGenericInstance_2") - public func Java_com_example_swift_SwiftModule__00024makeStringIDOptional__Ljava_lang_String_2_3BLorg_swift_swiftkit_core__1OutSwiftGenericInstance_2(environment: UnsafeMutablePointer!, thisClass: jclass, value: jstring?, result_discriminator$: jbyteArray?, resultWrappedOut: jobject?) { + public func Java_com_example_swift_SwiftModule__00024makeStringIDOptional__Ljava_lang_String_2_3BLorg_swift_swiftkit_core__1OutSwiftGenericInstance_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, value: JNITypes.jstring?, result_discriminator$: JNITypes.jbyteArray?, resultWrappedOut: JNITypes.jobject?) { if let innerResult$ = SwiftModule.makeStringIDOptional(String(fromJNI: value, in: environment)) { let resultWrapped$ = UnsafeMutablePointer>.allocate(capacity: 1) resultWrapped$.initialize(to: innerResult$) let resultWrappedBits$ = Int64(Int(bitPattern: resultWrapped$)) do { - environment.interface.SetLongField(environment, resultWrappedOut, _JNIMethodIDCache._OutSwiftGenericInstance.selfPointer, resultWrappedBits$.getJNIValue(in: environment)) + environment.swiftInterface.SetLongField(environment, resultWrappedOut, _JNIMethodIDCache._OutSwiftGenericInstance.selfPointer, resultWrappedBits$.getJNIValue(in: environment)) let metadataPointer = unsafeBitCast(MyID.self, to: UnsafeRawPointer.self) let metadataPointerBits$ = Int64(Int(bitPattern: metadataPointer)) - environment.interface.SetLongField(environment, resultWrappedOut, _JNIMethodIDCache._OutSwiftGenericInstance.selfTypePointer, metadataPointerBits$.getJNIValue(in: environment)) + environment.swiftInterface.SetLongField(environment, resultWrappedOut, _JNIMethodIDCache._OutSwiftGenericInstance.selfTypePointer, metadataPointerBits$.getJNIValue(in: environment)) } var flag$ = Int8(1) - environment.interface.SetByteArrayRegion(environment, result_discriminator$, 0, 1, &flag$) + environment.swiftInterface.SetByteArrayRegion(environment, result_discriminator$, 0, 1, &flag$) } else { var flag$ = Int8(0) - environment.interface.SetByteArrayRegion(environment, result_discriminator$, 0, 1, &flag$) + environment.swiftInterface.SetByteArrayRegion(environment, result_discriminator$, 0, 1, &flag$) } return } @@ -134,7 +134,7 @@ struct JNIGenericCombinationTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024takeStringIDOptional__J") - public func Java_com_example_swift_SwiftModule__00024takeStringIDOptional__J(environment: UnsafeMutablePointer!, thisClass: jclass, value: jlong) { + public func Java_com_example_swift_SwiftModule__00024takeStringIDOptional__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, value: jlong) { let valueBits$ = Int(Int64(fromJNI: value, in: environment)) let value$ = UnsafeMutablePointer>(bitPattern: valueBits$) SwiftModule.takeStringIDOptional(value$?.pointee) @@ -197,25 +197,25 @@ struct JNIGenericCombinationTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024makeIDs__Ljava_lang_String_2JLorg_swift_swiftkit_core__1OutSwiftGenericInstance_2Lorg_swift_swiftkit_core__1OutSwiftGenericInstance_2") - public func Java_com_example_swift_SwiftModule__00024makeIDs__Ljava_lang_String_2JLorg_swift_swiftkit_core__1OutSwiftGenericInstance_2Lorg_swift_swiftkit_core__1OutSwiftGenericInstance_2(environment: UnsafeMutablePointer!, thisClass: jclass, stringValue: jstring?, intValue: jlong, result_0$Out: jobject?, result_1$Out: jobject?) { + public func Java_com_example_swift_SwiftModule__00024makeIDs__Ljava_lang_String_2JLorg_swift_swiftkit_core__1OutSwiftGenericInstance_2Lorg_swift_swiftkit_core__1OutSwiftGenericInstance_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, stringValue: JNITypes.jstring?, intValue: jlong, result_0$Out: JNITypes.jobject?, result_1$Out: JNITypes.jobject?) { let tupleResult$ = SwiftModule.makeIDs(String(fromJNI: stringValue, in: environment), Int64(fromJNI: intValue, in: environment)) let result_0$$ = UnsafeMutablePointer>.allocate(capacity: 1) result_0$$.initialize(to: tupleResult$.0) let result_0$Bits$ = Int64(Int(bitPattern: result_0$$)) do { - environment.interface.SetLongField(environment, result_0$Out, _JNIMethodIDCache._OutSwiftGenericInstance.selfPointer, result_0$Bits$.getJNIValue(in: environment)) + environment.swiftInterface.SetLongField(environment, result_0$Out, _JNIMethodIDCache._OutSwiftGenericInstance.selfPointer, result_0$Bits$.getJNIValue(in: environment)) let metadataPointer = unsafeBitCast(MyID.self, to: UnsafeRawPointer.self) let metadataPointerBits$ = Int64(Int(bitPattern: metadataPointer)) - environment.interface.SetLongField(environment, result_0$Out, _JNIMethodIDCache._OutSwiftGenericInstance.selfTypePointer, metadataPointerBits$.getJNIValue(in: environment)) + environment.swiftInterface.SetLongField(environment, result_0$Out, _JNIMethodIDCache._OutSwiftGenericInstance.selfTypePointer, metadataPointerBits$.getJNIValue(in: environment)) } let result_1$$ = UnsafeMutablePointer>.allocate(capacity: 1) result_1$$.initialize(to: tupleResult$.1) let result_1$Bits$ = Int64(Int(bitPattern: result_1$$)) do { - environment.interface.SetLongField(environment, result_1$Out, _JNIMethodIDCache._OutSwiftGenericInstance.selfPointer, result_1$Bits$.getJNIValue(in: environment)) + environment.swiftInterface.SetLongField(environment, result_1$Out, _JNIMethodIDCache._OutSwiftGenericInstance.selfPointer, result_1$Bits$.getJNIValue(in: environment)) let metadataPointer = unsafeBitCast(MyID.self, to: UnsafeRawPointer.self) let metadataPointerBits$ = Int64(Int(bitPattern: metadataPointer)) - environment.interface.SetLongField(environment, result_1$Out, _JNIMethodIDCache._OutSwiftGenericInstance.selfTypePointer, metadataPointerBits$.getJNIValue(in: environment)) + environment.swiftInterface.SetLongField(environment, result_1$Out, _JNIMethodIDCache._OutSwiftGenericInstance.selfTypePointer, metadataPointerBits$.getJNIValue(in: environment)) } return } @@ -257,7 +257,7 @@ struct JNIGenericCombinationTests { expectedChunks: [ #""" @_cdecl("Java_com_example_swift_SwiftModule__00024takeValues__JJ_3Ljava_lang_String_2_3J") - public func Java_com_example_swift_SwiftModule__00024takeValues__JJ_3Ljava_lang_String_2_3J(environment: UnsafeMutablePointer!, thisClass: jclass, tuple_0: jlong, tuple_1: jlong, result_0$: jobjectArray?, result_1$: jlongArray?) { + public func Java_com_example_swift_SwiftModule__00024takeValues__JJ_3Ljava_lang_String_2_3J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, tuple_0: jlong, tuple_1: jlong, result_0$: JNITypes.jobjectArray?, result_1$: JNITypes.jlongArray?) { assert(tuple_0 != 0, "tuple_0 memory address was null") let tuple_0Bits$ = Int(Int64(fromJNI: tuple_0, in: environment)) let tuple_0$ = UnsafeMutablePointer>(bitPattern: tuple_0Bits$) @@ -272,9 +272,9 @@ struct JNIGenericCombinationTests { } let tupleResult$ = SwiftModule.takeValues(from: (tuple_0$.pointee, tuple_1$.pointee)) let element_0_jni$ = tupleResult$.0.getJNILocalRefValue(in: environment) - environment.interface.SetObjectArrayElement(environment, result_0$, 0, element_0_jni$) + environment.swiftInterface.SetObjectArrayElement(environment, result_0$, 0, element_0_jni$) var element_1_jni$ = tupleResult$.1.getJNILocalRefValue(in: environment) - environment.interface.SetLongArrayRegion(environment, result_1$, 0, 1, &element_1_jni$) + environment.swiftInterface.SetLongArrayRegion(environment, result_1$, 0, 1, &element_1_jni$) return } """# diff --git a/Tests/JExtractSwiftTests/JNI/JNIGenericTypeTests.swift b/Tests/JExtractSwiftTests/JNI/JNIGenericTypeTests.swift index 96f92fcf7..e426b29c1 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIGenericTypeTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIGenericTypeTests.swift @@ -90,13 +90,13 @@ struct JNIGenericTypeTests { expectedChunks: [ """ protocol _SwiftModule_MyID_opener { - static func _get_description(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) -> jstring? + static func _get_description(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong) -> JNITypes.jstring? ... } """, #""" extension MyID: _SwiftModule_MyID_opener { - static func _get_description(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) -> jstring? { + static func _get_description(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong) -> JNITypes.jstring? { assert(selfPointer != 0, "selfPointer memory address was null") let selfPointerBits$ = Int(Int64(fromJNI: selfPointer, in: environment)) let selfPointer$ = UnsafeMutablePointer>(bitPattern: selfPointerBits$) @@ -110,7 +110,7 @@ struct JNIGenericTypeTests { """#, """ @_cdecl("Java_com_example_swift_MyID__00024getDescription__JJ") - public func Java_com_example_swift_MyID__00024getDescription__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong, selfTypePointer: jlong) -> jstring? { + public func Java_com_example_swift_MyID__00024getDescription__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong, selfTypePointer: jlong) -> JNITypes.jstring? { let selfTypePointerBits$ = Int(Int64(fromJNI: selfTypePointer, in: environment)) guard let selfTypePointer$ = UnsafeRawPointer(bitPattern: selfTypePointerBits$) else { fatalError("selfTypePointer metadata address was null") @@ -163,22 +163,22 @@ struct JNIGenericTypeTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024makeStringID__Ljava_lang_String_2Lorg_swift_swiftkit_core__1OutSwiftGenericInstance_2") - public func Java_com_example_swift_SwiftModule__00024makeStringID__Ljava_lang_String_2Lorg_swift_swiftkit_core__1OutSwiftGenericInstance_2(environment: UnsafeMutablePointer!, thisClass: jclass, value: jstring?, resultOut: jobject?) { + public func Java_com_example_swift_SwiftModule__00024makeStringID__Ljava_lang_String_2Lorg_swift_swiftkit_core__1OutSwiftGenericInstance_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, value: JNITypes.jstring?, resultOut: JNITypes.jobject?) { let result$ = UnsafeMutablePointer>.allocate(capacity: 1) result$.initialize(to: SwiftModule.makeStringID(String(fromJNI: value, in: environment))) let resultBits$ = Int64(Int(bitPattern: result$)) do { - environment.interface.SetLongField(environment, resultOut, _JNIMethodIDCache._OutSwiftGenericInstance.selfPointer, resultBits$.getJNIValue(in: environment)) + environment.swiftInterface.SetLongField(environment, resultOut, _JNIMethodIDCache._OutSwiftGenericInstance.selfPointer, resultBits$.getJNIValue(in: environment)) let metadataPointer = unsafeBitCast(MyID.self, to: UnsafeRawPointer.self) let metadataPointerBits$ = Int64(Int(bitPattern: metadataPointer)) - environment.interface.SetLongField(environment, resultOut, _JNIMethodIDCache._OutSwiftGenericInstance.selfTypePointer, metadataPointerBits$.getJNIValue(in: environment)) + environment.swiftInterface.SetLongField(environment, resultOut, _JNIMethodIDCache._OutSwiftGenericInstance.selfTypePointer, metadataPointerBits$.getJNIValue(in: environment)) } return } """, """ @_cdecl("Java_com_example_swift_SwiftModule__00024takeIntID__J") - public func Java_com_example_swift_SwiftModule__00024takeIntID__J(environment: UnsafeMutablePointer!, thisClass: jclass, value: jlong) -> jlong { + public func Java_com_example_swift_SwiftModule__00024takeIntID__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, value: jlong) -> jlong { assert(value != 0, "value memory address was null") let valueBits$ = Int(Int64(fromJNI: value, in: environment)) let value$ = UnsafeMutablePointer>(bitPattern: valueBits$) @@ -211,12 +211,12 @@ struct JNIGenericTypeTests { expectedChunks: [ """ protocol _SwiftModule_Box_opener { - static func _describeElement(environment: UnsafeMutablePointer!, thisClass: jclass) -> jstring? + static func _describeElement(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> JNITypes.jstring? } """, #""" extension Box: _SwiftModule_Box_opener { - static func _describeElement(environment: UnsafeMutablePointer!, thisClass: jclass) -> jstring? { + static func _describeElement(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> JNITypes.jstring? { return Box.describeElement().getJNILocalRefValue(in: environment) } } @@ -244,12 +244,12 @@ struct JNIGenericTypeTests { expectedChunks: [ """ protocol _SwiftModule_VariadicBox_opener { - static func _describe(environment: UnsafeMutablePointer!, thisClass: jclass) -> jstring? + static func _describe(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> JNITypes.jstring? } """, #""" extension VariadicBox: _SwiftModule_VariadicBox_opener { - static func _describe(environment: UnsafeMutablePointer!, thisClass: jclass) -> jstring? { + static func _describe(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> JNITypes.jstring? { return VariadicBox.describe().getJNILocalRefValue(in: environment) } } @@ -290,7 +290,7 @@ struct JNIGenericTypeTests { detectChunkByInitialLines: 1, expectedChunks: [ #""" - public func Java_com_example_swift_MyEnum__00024getAsFoo__J_3BLorg_swift_swiftkit_core__1OutSwiftGenericInstance_2(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong, result_discriminator$: jbyteArray?, resultWrappedOut: jobject?) { + public func Java_com_example_swift_MyEnum__00024getAsFoo__J_3BLorg_swift_swiftkit_core__1OutSwiftGenericInstance_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong, result_discriminator$: JNITypes.jbyteArray?, resultWrappedOut: JNITypes.jobject?) { """# ] ) @@ -354,7 +354,7 @@ struct JNIGenericTypeTests { expectedChunks: [ #""" extension Foo.Bar: _SwiftModule_Foo_Bar_opener { - static func _work(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) { + static func _work(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong) { ... let selfPointer$ = UnsafeMutablePointer>(bitPattern: selfPointerBits$) guard let selfPointer$ else { diff --git a/Tests/JExtractSwiftTests/JNI/JNIIntConversionChecksTests.swift b/Tests/JExtractSwiftTests/JNI/JNIIntConversionChecksTests.swift index a156c8680..46b274219 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIIntConversionChecksTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIIntConversionChecksTests.swift @@ -83,7 +83,7 @@ struct JNIIntConversionChecksTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyStruct__00024init__J") - public func Java_com_example_swift_MyStruct__00024init__J(environment: UnsafeMutablePointer!, thisClass: jclass, normalInt: jlong) -> jlong { + public func Java_com_example_swift_MyStruct__00024init__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, normalInt: jlong) -> jlong { let normalInt$indirect = Int64(fromJNI: normalInt, in: environment) #if _pointerBitWidth(_32) guard normalInt$indirect >= Int32.min && normalInt$indirect <= Int32.max else { @@ -109,7 +109,7 @@ struct JNIIntConversionChecksTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyStruct__00024init__J") - public func Java_com_example_swift_MyStruct__00024init__J(environment: UnsafeMutablePointer!, thisClass: jclass, unsignedInt: jlong) -> jlong { + public func Java_com_example_swift_MyStruct__00024init__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, unsignedInt: jlong) -> jlong { let unsignedInt$indirect = UInt64(fromJNI: unsignedInt, in: environment) #if _pointerBitWidth(_32) guard unsignedInt$indirect >= UInt32.min && unsignedInt$indirect <= UInt32.max else { @@ -135,7 +135,7 @@ struct JNIIntConversionChecksTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyStruct__00024init__BJ") - public func Java_com_example_swift_MyStruct__00024init__BJ(environment: UnsafeMutablePointer!, thisClass: jclass, optionalInt_discriminator: jbyte, optionalInt_value: jlong) -> jlong { + public func Java_com_example_swift_MyStruct__00024init__BJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, optionalInt_discriminator: jbyte, optionalInt_value: jlong) -> jlong { let optionalInt$indirect = Int64(fromJNI: optionalInt_value, in: environment) #if _pointerBitWidth(_32) guard optionalInt$indirect >= Int32.min && optionalInt$indirect <= Int32.max else { @@ -161,7 +161,7 @@ struct JNIIntConversionChecksTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyStruct__00024init__BJ") - public func Java_com_example_swift_MyStruct__00024init__BJ(environment: UnsafeMutablePointer!, thisClass: jclass, optionalUInt_discriminator: jbyte, optionalUInt_value: jlong) -> jlong { + public func Java_com_example_swift_MyStruct__00024init__BJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, optionalUInt_discriminator: jbyte, optionalUInt_value: jlong) -> jlong { let optionalUInt$indirect = UInt64(fromJNI: optionalUInt_value, in: environment) #if _pointerBitWidth(_32) guard optionalUInt$indirect >= UInt32.min && optionalUInt$indirect <= UInt32.max else { @@ -187,7 +187,7 @@ struct JNIIntConversionChecksTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyStruct__00024getOptionalInt__J_3B") - public func Java_com_example_swift_MyStruct__00024getOptionalInt__J_3B(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong, result_discriminator$: jbyteArray?) -> jlong { + public func Java_com_example_swift_MyStruct__00024getOptionalInt__J_3B(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong, result_discriminator$: JNITypes.jbyteArray?) -> jlong { """, """ let result$: jlong @@ -206,7 +206,7 @@ struct JNIIntConversionChecksTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyStruct__00024getOptionalUInt__J_3B") - public func Java_com_example_swift_MyStruct__00024getOptionalUInt__J_3B(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong, result_discriminator$: jbyteArray?) -> jlong { + public func Java_com_example_swift_MyStruct__00024getOptionalUInt__J_3B(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong, result_discriminator$: JNITypes.jbyteArray?) -> jlong { """, """ let result$: jlong @@ -225,7 +225,7 @@ struct JNIIntConversionChecksTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyStruct__00024setUnsignedInt__JJ") - public func Java_com_example_swift_MyStruct__00024setUnsignedInt__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, newValue: jlong, selfPointer: jlong) { + public func Java_com_example_swift_MyStruct__00024setUnsignedInt__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, newValue: jlong, selfPointer: jlong) { let newValue$indirect = UInt64(fromJNI: newValue, in: environment) #if _pointerBitWidth(_32) guard newValue$indirect >= UInt32.min && newValue$indirect <= UInt32.max else { @@ -254,7 +254,7 @@ struct JNIIntConversionChecksTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyStruct__00024getUnsignedInt__J") - public func Java_com_example_swift_MyStruct__00024getUnsignedInt__J(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) -> jlong { + public func Java_com_example_swift_MyStruct__00024getUnsignedInt__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong) -> jlong { assert(selfPointer != 0, "selfPointer memory address was null") let selfPointerBits$ = Int(Int64(fromJNI: selfPointer, in: environment)) let selfPointer$ = UnsafeMutablePointer(bitPattern: selfPointerBits$) @@ -275,7 +275,7 @@ struct JNIIntConversionChecksTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyStruct__00024setNormalInt__JJ") - public func Java_com_example_swift_MyStruct__00024setNormalInt__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, newValue: jlong, selfPointer: jlong) { + public func Java_com_example_swift_MyStruct__00024setNormalInt__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, newValue: jlong, selfPointer: jlong) { let newValue$indirect = Int64(fromJNI: newValue, in: environment) #if _pointerBitWidth(_32) guard newValue$indirect >= Int32.min && newValue$indirect <= Int32.max else { @@ -304,7 +304,7 @@ struct JNIIntConversionChecksTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyStruct__00024dummyFunc__JJ") - public func Java_com_example_swift_MyStruct__00024dummyFunc__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, arg: jlong, selfPointer: jlong) -> jlong { + public func Java_com_example_swift_MyStruct__00024dummyFunc__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, arg: jlong, selfPointer: jlong) -> jlong { let arg$indirect = Int64(fromJNI: arg, in: environment) #if _pointerBitWidth(_32) guard arg$indirect >= Int32.min && arg$indirect <= Int32.max else { @@ -333,7 +333,7 @@ struct JNIIntConversionChecksTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyStruct__00024dummyFunc__JJ") - public func Java_com_example_swift_MyStruct__00024dummyFunc__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, arg: jlong, selfPointer: jlong) -> jlong { + public func Java_com_example_swift_MyStruct__00024dummyFunc__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, arg: jlong, selfPointer: jlong) -> jlong { let arg$indirect = UInt64(fromJNI: arg, in: environment) #if _pointerBitWidth(_32) guard arg$indirect >= UInt32.min && arg$indirect <= UInt32.max else { @@ -361,7 +361,7 @@ struct JNIIntConversionChecksTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyEnum__00024secondCase__J") - public func Java_com_example_swift_MyEnum__00024secondCase__J(environment: UnsafeMutablePointer!, thisClass: jclass, arg0: jlong) -> jlong { + public func Java_com_example_swift_MyEnum__00024secondCase__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, arg0: jlong) -> jlong { let arg0$indirect = UInt64(fromJNI: arg0, in: environment) #if _pointerBitWidth(_32) guard arg0$indirect >= UInt32.min && arg0$indirect <= UInt32.max else { diff --git a/Tests/JExtractSwiftTests/JNI/JNIJavaKitTests.swift b/Tests/JExtractSwiftTests/JNI/JNIJavaKitTests.swift index db070683c..65e54d8fa 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIJavaKitTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIJavaKitTests.swift @@ -63,7 +63,7 @@ struct JNIJavaKitTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024function__Ljava_lang_Long_2Ljava_lang_Integer_2J") - public func Java_com_example_swift_SwiftModule__00024function__Ljava_lang_Long_2Ljava_lang_Integer_2J(environment: UnsafeMutablePointer!, thisClass: jclass, javaLong: jobject?, javaInteger: jobject?, int: jlong) { + public func Java_com_example_swift_SwiftModule__00024function__Ljava_lang_Long_2Ljava_lang_Integer_2J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, javaLong: JNITypes.jobject?, javaInteger: JNITypes.jobject?, int: jlong) { guard let javaLong_unwrapped$ = javaLong else { fatalError("javaLong was null in call to \\(#function), but Swift requires non-optional!") } @@ -114,7 +114,7 @@ struct JNIJavaKitTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024function__") - public func Java_com_example_swift_SwiftModule__00024function__(environment: UnsafeMutablePointer!, thisClass: jclass) -> jobject? { + public func Java_com_example_swift_SwiftModule__00024function__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> JNITypes.jobject? { return (SwiftModule.function() as Optional).getJNILocalRefValue(in: environment) } """ @@ -159,7 +159,7 @@ struct JNIJavaKitTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024function__") - public func Java_com_example_swift_SwiftModule__00024function__(environment: UnsafeMutablePointer!, thisClass: jclass) -> jobject? { + public func Java_com_example_swift_SwiftModule__00024function__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> JNITypes.jobject? { return (SwiftModule.function() as Optional).getJNILocalRefValue(in: environment) } """ @@ -204,7 +204,7 @@ struct JNIJavaKitTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024function__") - public func Java_com_example_swift_SwiftModule__00024function__(environment: UnsafeMutablePointer!, thisClass: jclass) -> jobjectArray? { + public func Java_com_example_swift_SwiftModule__00024function__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> JNITypes.jobjectArray? { return (SwiftModule.function() as Optional).getJNILocalRefValue(in: environment) } """ diff --git a/Tests/JExtractSwiftTests/JNI/JNIJobjectBridgeTests.swift b/Tests/JExtractSwiftTests/JNI/JNIJobjectBridgeTests.swift index 60c936cb3..b2cc43956 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIJobjectBridgeTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIJobjectBridgeTests.swift @@ -40,7 +40,7 @@ struct JNIJobjectBridgeTests { className: "com/example/swift/ReefFish", methods: [wrapMemoryAddressUnsafeMethod] ) - static var javaClass: jclass { + static var javaClass: JNITypes.jclass { cache.javaClass } static var wrapMemoryAddressUnsafe: jmethodID { @@ -51,7 +51,7 @@ struct JNIJobjectBridgeTests { struct _JNIBridge_ReefFish: JextractedTypeBridge { typealias SwiftType = ReefFish - static var javaClass: jclass { + static var javaClass: JNITypes.jclass { _JNI_ReefFish.javaClass } diff --git a/Tests/JExtractSwiftTests/JNI/JNIModuleTests.swift b/Tests/JExtractSwiftTests/JNI/JNIModuleTests.swift index 07fbda3a0..2df61211c 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIModuleTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIModuleTests.swift @@ -131,19 +131,19 @@ struct JNIModuleTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024helloWorld__") - public func Java_com_example_swift_SwiftModule__00024helloWorld__(environment: UnsafeMutablePointer!, thisClass: jclass) { + public func Java_com_example_swift_SwiftModule__00024helloWorld__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) { SwiftModule.helloWorld() } """, """ @_cdecl("Java_com_example_swift_SwiftModule__00024takeIntegers__BSIJ") - public func Java_com_example_swift_SwiftModule__00024takeIntegers__BSIJ(environment: UnsafeMutablePointer!, thisClass: jclass, i1: jbyte, i2: jshort, i3: jint, i4: jlong) -> jchar { + public func Java_com_example_swift_SwiftModule__00024takeIntegers__BSIJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, i1: jbyte, i2: jshort, i3: jint, i4: jlong) -> jchar { return SwiftModule.takeIntegers(i1: Int8(fromJNI: i1, in: environment), i2: Int16(fromJNI: i2, in: environment), i3: Int32(fromJNI: i3, in: environment), i4: Int64(fromJNI: i4, in: environment)).getJNILocalRefValue(in: environment) } """, """ @_cdecl("Java_com_example_swift_SwiftModule__00024otherPrimitives__ZFD") - public func Java_com_example_swift_SwiftModule__00024otherPrimitives__ZFD(environment: UnsafeMutablePointer!, thisClass: jclass, b: jboolean, f: jfloat, d: jdouble) { + public func Java_com_example_swift_SwiftModule__00024otherPrimitives__ZFD(environment: JNIEnvironment!, thisClass: JNITypes.jclass, b: jboolean, f: jfloat, d: jdouble) { SwiftModule.otherPrimitives(b: Bool(fromJNI: b, in: environment), f: Float(fromJNI: f, in: environment), d: Double(fromJNI: d, in: environment)) } """, @@ -186,7 +186,7 @@ struct JNIModuleTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024copy__Ljava_lang_String_2") - public func Java_com_example_swift_SwiftModule__00024copy__Ljava_lang_String_2(environment: UnsafeMutablePointer!, thisClass: jclass, string: jstring?) -> jstring? { + public func Java_com_example_swift_SwiftModule__00024copy__Ljava_lang_String_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, string: JNITypes.jstring?) -> JNITypes.jstring? { return SwiftModule.copy(String(fromJNI: string, in: environment)).getJNILocalRefValue(in: environment) } """ @@ -243,7 +243,7 @@ struct JNIModuleTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024methodA__") - public func Java_com_example_swift_SwiftModule__00024methodA__(environment: UnsafeMutablePointer!, thisClass: jclass) { + public func Java_com_example_swift_SwiftModule__00024methodA__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) { do { try SwiftModule.methodA() } catch { @@ -254,7 +254,7 @@ struct JNIModuleTests { """, """ @_cdecl("Java_com_example_swift_SwiftModule__00024methodB__") - public func Java_com_example_swift_SwiftModule__00024methodB__(environment: UnsafeMutablePointer!, thisClass: jclass) -> jlong { + public func Java_com_example_swift_SwiftModule__00024methodB__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> jlong { do { return try SwiftModule.methodB().getJNILocalRefValue(in: environment) } catch { @@ -265,7 +265,7 @@ struct JNIModuleTests { """, """ @_cdecl("Java_com_example_swift_SwiftModule__00024methodC__") - public func Java_com_example_swift_SwiftModule__00024methodC__(environment: UnsafeMutablePointer!, thisClass: jclass) -> jstring? { + public func Java_com_example_swift_SwiftModule__00024methodC__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> JNITypes.jstring? { do { return try SwiftModule.methodC().getJNILocalRefValue(in: environment) } catch { diff --git a/Tests/JExtractSwiftTests/JNI/JNINestedTypesTests.swift b/Tests/JExtractSwiftTests/JNI/JNINestedTypesTests.swift index ea052c56a..425acf2ac 100644 --- a/Tests/JExtractSwiftTests/JNI/JNINestedTypesTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNINestedTypesTests.swift @@ -76,25 +76,25 @@ struct JNINestedTypesTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_A__00024typeMetadataAddressDowncall__") - public func Java_com_example_swift_A__00024typeMetadataAddressDowncall__(environment: UnsafeMutablePointer!, thisClass: jclass) -> jlong { + public func Java_com_example_swift_A__00024typeMetadataAddressDowncall__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> jlong { ... } """, """ @_cdecl("Java_com_example_swift_A_00024B__00024typeMetadataAddressDowncall__") - public func Java_com_example_swift_A_00024B__00024typeMetadataAddressDowncall__(environment: UnsafeMutablePointer!, thisClass: jclass) -> jlong { + public func Java_com_example_swift_A_00024B__00024typeMetadataAddressDowncall__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> jlong { ... } """, """ @_cdecl("Java_com_example_swift_A_00024B_00024C__00024typeMetadataAddressDowncall__") - public func Java_com_example_swift_A_00024B_00024C__00024typeMetadataAddressDowncall__(environment: UnsafeMutablePointer!, thisClass: jclass) -> jlong { + public func Java_com_example_swift_A_00024B_00024C__00024typeMetadataAddressDowncall__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> jlong { ... } """, """ @_cdecl("Java_com_example_swift_A_00024B_00024C__00024h__JJ") - public func Java_com_example_swift_A_00024B_00024C__00024h__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, b: jlong, selfPointer: jlong) { + public func Java_com_example_swift_A_00024B_00024C__00024h__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, b: jlong, selfPointer: jlong) { ... } """, diff --git a/Tests/JExtractSwiftTests/JNI/JNIOperatorsTests.swift b/Tests/JExtractSwiftTests/JNI/JNIOperatorsTests.swift index 9863d109d..012c676bd 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIOperatorsTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIOperatorsTests.swift @@ -138,7 +138,7 @@ struct JNIOperatorsTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_Number__00024plus__JJ") - public func Java_com_example_swift_Number__00024plus__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, left: jlong, right: jlong) -> jlong { + public func Java_com_example_swift_Number__00024plus__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, left: jlong, right: jlong) -> jlong { ... let result$ = UnsafeMutablePointer.allocate(capacity: 1) result$.initialize(to: (((left$.pointee) + (right$.pointee))) diff --git a/Tests/JExtractSwiftTests/JNI/JNIOptionalTests.swift b/Tests/JExtractSwiftTests/JNI/JNIOptionalTests.swift index 5847f34db..08f856979 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIOptionalTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIOptionalTests.swift @@ -71,7 +71,7 @@ struct JNIOptionalTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024optionalSugar__BJ") - public func Java_com_example_swift_SwiftModule__00024optionalSugar__BJ(environment: UnsafeMutablePointer!, thisClass: jclass, arg_discriminator: jbyte, arg_value: jlong) -> jlong { + public func Java_com_example_swift_SwiftModule__00024optionalSugar__BJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, arg_discriminator: jbyte, arg_value: jlong) -> jlong { let result_value$ = SwiftModule.optionalSugar(arg_discriminator == 1 ? Int64(fromJNI: arg_value, in: environment) : nil).map { Int64($0) << 32 | Int64(1) } ?? 0 @@ -121,17 +121,17 @@ struct JNIOptionalTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024optionalExplicit__BLjava_lang_String_2_3B") - public func Java_com_example_swift_SwiftModule__00024optionalExplicit__BLjava_lang_String_2_3B(environment: UnsafeMutablePointer!, thisClass: jclass, arg_discriminator: jbyte, arg_value: jstring?, result_discriminator$: jbyteArray?) -> jstring? { - let result$: jstring? + public func Java_com_example_swift_SwiftModule__00024optionalExplicit__BLjava_lang_String_2_3B(environment: JNIEnvironment!, thisClass: JNITypes.jclass, arg_discriminator: jbyte, arg_value: JNITypes.jstring?, result_discriminator$: JNITypes.jbyteArray?) -> JNITypes.jstring? { + let result$: JNITypes.jstring? if let innerResult$ = SwiftModule.optionalExplicit(arg_discriminator == 1 ? String(fromJNI: arg_value, in: environment) : nil) { result$ = innerResult$.getJNIValue(in: environment) var flag$ = Int8(1) - environment.interface.SetByteArrayRegion(environment, result_discriminator$, 0, 1, &flag$) + environment.swiftInterface.SetByteArrayRegion(environment, result_discriminator$, 0, 1, &flag$) } else { result$ = nil var flag$ = Int8(0) - environment.interface.SetByteArrayRegion(environment, result_discriminator$, 0, 1, &flag$) + environment.swiftInterface.SetByteArrayRegion(environment, result_discriminator$, 0, 1, &flag$) } return result$ } @@ -179,7 +179,7 @@ struct JNIOptionalTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024optionalClass__J_3B") - public func Java_com_example_swift_SwiftModule__00024optionalClass__J_3B(environment: UnsafeMutablePointer!, thisClass: jclass, arg: jlong, result_discriminator$: jbyteArray?) -> jlong { + public func Java_com_example_swift_SwiftModule__00024optionalClass__J_3B(environment: JNIEnvironment!, thisClass: JNITypes.jclass, arg: jlong, result_discriminator$: JNITypes.jbyteArray?) -> jlong { let argBits$ = Int(Int64(fromJNI: arg, in: environment)) let arg$ = UnsafeMutablePointer(bitPattern: argBits$) let result$: jlong @@ -189,12 +189,12 @@ struct JNIOptionalTests { let resultWrappedBits$ = Int64(Int(bitPattern: resultWrapped$)) result$ = resultWrappedBits$.getJNILocalRefValue(in: environment) var flag$ = Int8(1) - environment.interface.SetByteArrayRegion(environment, result_discriminator$, 0, 1, &flag$) + environment.swiftInterface.SetByteArrayRegion(environment, result_discriminator$, 0, 1, &flag$) } else { result$ = 0 var flag$ = Int8(0) - environment.interface.SetByteArrayRegion(environment, result_discriminator$, 0, 1, &flag$) + environment.swiftInterface.SetByteArrayRegion(environment, result_discriminator$, 0, 1, &flag$) } return result$ } @@ -240,7 +240,7 @@ struct JNIOptionalTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024optionalJavaKitClass__Ljava_lang_Long_2") - public func Java_com_example_swift_SwiftModule__00024optionalJavaKitClass__Ljava_lang_Long_2(environment: UnsafeMutablePointer!, thisClass: jclass, arg: jobject?) { + public func Java_com_example_swift_SwiftModule__00024optionalJavaKitClass__Ljava_lang_Long_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, arg: JNITypes.jobject?) { SwiftModule.optionalJavaKitClass(arg.map { return JavaLong(javaThis: $0, environment: environment) } diff --git a/Tests/JExtractSwiftTests/JNI/JNIProtocolTests.swift b/Tests/JExtractSwiftTests/JNI/JNIProtocolTests.swift index fc1e971bf..59b27ccc6 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIProtocolTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIProtocolTests.swift @@ -200,9 +200,9 @@ struct JNIProtocolTests { """, """ @_cdecl("Java_com_example_swift_SwiftModule__00024takeProtocol__Ljava_lang_Object_2Ljava_lang_Object_2") - public func Java_com_example_swift_SwiftModule__00024takeProtocol__Ljava_lang_Object_2Ljava_lang_Object_2(environment: UnsafeMutablePointer!, thisClass: jclass, x: jobject?, y: jobject?) { + public func Java_com_example_swift_SwiftModule__00024takeProtocol__Ljava_lang_Object_2Ljava_lang_Object_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, x: JNITypes.jobject?, y: JNITypes.jobject?) { let xswiftObject$: (any SomeProtocol) - if environment.interface.IsInstanceOf(environment, x, _JNIMethodIDCache.JNISwiftInstance.class) != 0 { + if environment.swiftInterface.IsInstanceOf(environment, x, _JNIMethodIDCache.JNISwiftInstance.class) != 0 { ... let xpointer$DynamicType$: Any.Type = unsafeBitCast(xpointer$TypeMetadataPointer$, to: Any.Type.self) guard let xpointer$RawPointer$ = UnsafeMutableRawPointer(bitPattern: Int(Int64(fromJNI: xpointer$, in: environment))) else { @@ -222,7 +222,7 @@ struct JNIProtocolTests { xswiftObject$ = _SwiftModule_takeProtocol_x_Wrapper(_javaSomeProtocolInterface: JavaSomeProtocol(javaThis: x!, environment: environment)) } let yswiftObject$: (any SomeProtocol) - if environment.interface.IsInstanceOf(environment, y, _JNIMethodIDCache.JNISwiftInstance.class) != 0 { + if environment.swiftInterface.IsInstanceOf(environment, y, _JNIMethodIDCache.JNISwiftInstance.class) != 0 { ... yswiftObject$ = ypointer$Existential$ } @@ -276,9 +276,9 @@ struct JNIProtocolTests { """, """ @_cdecl("Java_com_example_swift_SwiftModule__00024takeGeneric__Ljava_lang_Object_2") - public func Java_com_example_swift_SwiftModule__00024takeGeneric__Ljava_lang_Object_2(environment: UnsafeMutablePointer!, thisClass: jclass, s: jobject?) { + public func Java_com_example_swift_SwiftModule__00024takeGeneric__Ljava_lang_Object_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, s: JNITypes.jobject?) { let sswiftObject$: (any SomeProtocol) - if environment.interface.IsInstanceOf(environment, s, _JNIMethodIDCache.JNISwiftInstance.class) != 0 { + if environment.swiftInterface.IsInstanceOf(environment, s, _JNIMethodIDCache.JNISwiftInstance.class) != 0 { ... sswiftObject$ = spointer$Existential$ } @@ -334,11 +334,11 @@ struct JNIProtocolTests { """, """ @_cdecl("Java_com_example_swift_SwiftModule__00024takeComposite__Ljava_lang_Object_2") - public func Java_com_example_swift_SwiftModule__00024takeComposite__Ljava_lang_Object_2(environment: UnsafeMutablePointer!, thisClass: jclass, x: jobject?) { + public func Java_com_example_swift_SwiftModule__00024takeComposite__Ljava_lang_Object_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, x: JNITypes.jobject?) { let xswiftObject$: (any (SomeProtocol & B)) - if environment.interface.IsInstanceOf(environment, x, _JNIMethodIDCache.JNISwiftInstance.class) != 0 { - let xpointer$ = environment.interface.CallLongMethodA(environment, x, _JNIMethodIDCache.JNISwiftInstance.memoryAddress, []) - let xtypeMetadata$ = environment.interface.CallLongMethodA(environment, x, _JNIMethodIDCache.JNISwiftInstance.typeMetadataAddress, []) + if environment.swiftInterface.IsInstanceOf(environment, x, _JNIMethodIDCache.JNISwiftInstance.class) != 0 { + let xpointer$ = environment.swiftInterface.CallLongMethodA(environment, x, _JNIMethodIDCache.JNISwiftInstance.memoryAddress, []) + let xtypeMetadata$ = environment.swiftInterface.CallLongMethodA(environment, x, _JNIMethodIDCache.JNISwiftInstance.typeMetadataAddress, []) guard let xpointer$TypeMetadataPointer$ = UnsafeRawPointer(bitPattern: Int(Int64(fromJNI: xtypeMetadata$, in: environment))) else { fatalError("xtypeMetadata$ memory address was null") } @@ -508,18 +508,18 @@ struct JNIProtocolTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024makeGreeter__Lorg_swift_swiftkit_core__1OutSwiftGenericInstance_2") - public func Java_com_example_swift_SwiftModule__00024makeGreeter__Lorg_swift_swiftkit_core__1OutSwiftGenericInstance_2(environment: UnsafeMutablePointer!, thisClass: jclass, resultOut: jobject?) { + public func Java_com_example_swift_SwiftModule__00024makeGreeter__Lorg_swift_swiftkit_core__1OutSwiftGenericInstance_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, resultOut: JNITypes.jobject?) { let resultExistential$: (any Greeter) = SwiftModule.makeGreeter() ... do { let (selfPointerBits$, selfTypePointerBits$) = resultBoxed$ - environment.interface.SetLongField(environment, resultOut, _JNIMethodIDCache._OutSwiftGenericInstance.selfPointer, selfPointerBits$.getJNIValue(in: environment)) - environment.interface.SetLongField(environment, resultOut, _JNIMethodIDCache._OutSwiftGenericInstance.selfTypePointer, selfTypePointerBits$.getJNIValue(in: environment)) + environment.swiftInterface.SetLongField(environment, resultOut, _JNIMethodIDCache._OutSwiftGenericInstance.selfPointer, selfPointerBits$.getJNIValue(in: environment)) + environment.swiftInterface.SetLongField(environment, resultOut, _JNIMethodIDCache._OutSwiftGenericInstance.selfTypePointer, selfTypePointerBits$.getJNIValue(in: environment)) } """, """ @_cdecl("Java_com_example_swift_GreeterBox__00024greeting__JJ") - public func Java_com_example_swift_GreeterBox__00024greeting__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong, selfTypePointer: jlong) -> jstring? { + public func Java_com_example_swift_GreeterBox__00024greeting__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong, selfTypePointer: jlong) -> JNITypes.jstring? { guard let selfPointerTypeMetadataPointer$ = UnsafeRawPointer(bitPattern: Int(Int64(fromJNI: selfTypePointer, in: environment))) else { fatalError("selfTypePointer memory address was null") } @@ -553,14 +553,14 @@ struct JNIProtocolTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_GreeterBox__00024getFavoriteNumber__JJ") - public func Java_com_example_swift_GreeterBox__00024getFavoriteNumber__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong, selfTypePointer: jlong) -> jlong { + public func Java_com_example_swift_GreeterBox__00024getFavoriteNumber__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong, selfTypePointer: jlong) -> jlong { ... return selfPointerExistential$.favoriteNumber.getJNILocalRefValue(in: environment) } """, """ @_cdecl("Java_com_example_swift_GreeterBox__00024setFavoriteNumber__JJJ") - public func Java_com_example_swift_GreeterBox__00024setFavoriteNumber__JJJ(environment: UnsafeMutablePointer!, thisClass: jclass, newValue: jlong, selfPointer: jlong, selfTypePointer: jlong) { + public func Java_com_example_swift_GreeterBox__00024setFavoriteNumber__JJJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, newValue: jlong, selfPointer: jlong, selfTypePointer: jlong) { ... #if hasFeature(ImplicitOpenExistentials) var selfPointerExistential$: (any Greeter) = selfPointerRawPointer$.load(as: selfPointerDynamicType$) as! (any Greeter) diff --git a/Tests/JExtractSwiftTests/JNI/JNISetTest.swift b/Tests/JExtractSwiftTests/JNI/JNISetTest.swift index 6a79c4c92..d003a35e5 100644 --- a/Tests/JExtractSwiftTests/JNI/JNISetTest.swift +++ b/Tests/JExtractSwiftTests/JNI/JNISetTest.swift @@ -48,7 +48,7 @@ struct JNISetTest { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024f__") - public func Java_com_example_swift_SwiftModule__00024f__(environment: UnsafeMutablePointer!, thisClass: jclass) -> jlong { + public func Java_com_example_swift_SwiftModule__00024f__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> jlong { return SwiftModule.f().setGetJNIValue(in: environment, elementBridge: JavaBoxableBridge.self) } """ @@ -86,7 +86,7 @@ struct JNISetTest { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024f__J") - public func Java_com_example_swift_SwiftModule__00024f__J(environment: UnsafeMutablePointer!, thisClass: jclass, set: jlong) { + public func Java_com_example_swift_SwiftModule__00024f__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, set: jlong) { SwiftModule.f(set: Set(fromJNI: set, in: environment, elementBridge: JavaBoxableBridge.self)) } """ @@ -124,7 +124,7 @@ struct JNISetTest { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024f__J") - public func Java_com_example_swift_SwiftModule__00024f__J(environment: UnsafeMutablePointer!, thisClass: jclass, set: jlong) -> jlong { + public func Java_com_example_swift_SwiftModule__00024f__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, set: jlong) -> jlong { return SwiftModule.f(set: Set(fromJNI: set, in: environment, elementBridge: JavaBoxableBridge.self)).setGetJNIValue(in: environment, elementBridge: JavaBoxableBridge.self) } """ @@ -219,7 +219,7 @@ struct JNISetTest { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024f__JJ") - public func Java_com_example_swift_SwiftModule__00024f__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, a: jlong, b: jlong) { + public func Java_com_example_swift_SwiftModule__00024f__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, a: jlong, b: jlong) { SwiftModule.f(a: Set(fromJNI: a, in: environment, elementBridge: JavaBoxableBridge.self), b: Set(fromJNI: b, in: environment, elementBridge: JavaBoxableBridge.self)) } """ @@ -260,7 +260,7 @@ struct JNISetTest { expectedChunks: [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024f__JLjava_lang_String_2") - public func Java_com_example_swift_SwiftModule__00024f__JLjava_lang_String_2(environment: UnsafeMutablePointer!, thisClass: jclass, set: jlong, element: jstring?) -> jlong { + public func Java_com_example_swift_SwiftModule__00024f__JLjava_lang_String_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, set: jlong, element: JNITypes.jstring?) -> jlong { return SwiftModule.f(set: Set(fromJNI: set, in: environment, elementBridge: JavaBoxableBridge.self), element: String(fromJNI: element, in: environment)).setGetJNIValue(in: environment, elementBridge: JavaBoxableBridge.self) } """ diff --git a/Tests/JExtractSwiftTests/JNI/JNIStructTests.swift b/Tests/JExtractSwiftTests/JNI/JNIStructTests.swift index c83c8af6e..562bfcdfe 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIStructTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIStructTests.swift @@ -121,7 +121,7 @@ struct JNIStructTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyStruct__00024init__JJ") - public func Java_com_example_swift_MyStruct__00024init__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, x: jlong, y: jlong) -> jlong { + public func Java_com_example_swift_MyStruct__00024init__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, x: jlong, y: jlong) -> jlong { let result$ = UnsafeMutablePointer.allocate(capacity: 1) result$.initialize(to: MyStruct.init(x: Int64(fromJNI: x, in: environment), y: Int64(fromJNI: y, in: environment))) let resultBits$ = Int64(Int(bitPattern: result$)) @@ -167,7 +167,7 @@ struct JNIStructTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyStruct__00024doSomething__JJ") - public func Java_com_example_swift_MyStruct__00024doSomething__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, x: jlong, selfPointer: jlong) { + public func Java_com_example_swift_MyStruct__00024doSomething__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, x: jlong, selfPointer: jlong) { assert(selfPointer != 0, "selfPointer memory address was null") let selfPointerBits$ = Int(Int64(fromJNI: selfPointer, in: environment)) let selfPointer$ = UnsafeMutablePointer(bitPattern: selfPointerBits$) diff --git a/Tests/JExtractSwiftTests/JNI/JNISubscriptsTests.swift b/Tests/JExtractSwiftTests/JNI/JNISubscriptsTests.swift index 4f241e517..3d5c459f8 100644 --- a/Tests/JExtractSwiftTests/JNI/JNISubscriptsTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNISubscriptsTests.swift @@ -176,7 +176,7 @@ struct JNISubscriptsTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyStruct__00024getSubscript__J") - public func Java_com_example_swift_MyStruct__00024getSubscript__J(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) -> jdouble { + public func Java_com_example_swift_MyStruct__00024getSubscript__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong) -> jdouble { assert(selfPointer != 0, "selfPointer memory address was null") let selfPointerBits$ = Int(Int64(fromJNI: selfPointer, in: environment)) let selfPointer$ = UnsafeMutablePointer(bitPattern: selfPointerBits$) @@ -187,7 +187,7 @@ struct JNISubscriptsTests { """, """ @_cdecl("Java_com_example_swift_MyStruct__00024setSubscript__DJ") - public func Java_com_example_swift_MyStruct__00024setSubscript__DJ(environment: UnsafeMutablePointer!, thisClass: jclass, newValue: jdouble, selfPointer: jlong) { + public func Java_com_example_swift_MyStruct__00024setSubscript__DJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, newValue: jdouble, selfPointer: jlong) { assert(selfPointer != 0, "selfPointer memory address was null") let selfPointerBits$ = Int(Int64(fromJNI: selfPointer, in: environment)) let selfPointer$ = UnsafeMutablePointer(bitPattern: selfPointerBits$) @@ -209,7 +209,7 @@ struct JNISubscriptsTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyStruct__00024getSubscript__IJ") - public func Java_com_example_swift_MyStruct__00024getSubscript__IJ(environment: UnsafeMutablePointer!, thisClass: jclass, index: jint, selfPointer: jlong) -> jint { + public func Java_com_example_swift_MyStruct__00024getSubscript__IJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, index: jint, selfPointer: jlong) -> jint { assert(selfPointer != 0, "selfPointer memory address was null") let selfPointerBits$ = Int(Int64(fromJNI: selfPointer, in: environment)) let selfPointer$ = UnsafeMutablePointer(bitPattern: selfPointerBits$) @@ -220,7 +220,7 @@ struct JNISubscriptsTests { """, """ @_cdecl("Java_com_example_swift_MyStruct__00024setSubscript__IIJ") - public func Java_com_example_swift_MyStruct__00024setSubscript__IIJ(environment: UnsafeMutablePointer!, thisClass: jclass, index: jint, newValue: jint, selfPointer: jlong) { + public func Java_com_example_swift_MyStruct__00024setSubscript__IIJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, index: jint, newValue: jint, selfPointer: jlong) { assert(selfPointer != 0, "selfPointer memory address was null") let selfPointerBits$ = Int(Int64(fromJNI: selfPointer, in: environment)) let selfPointer$ = UnsafeMutablePointer(bitPattern: selfPointerBits$) diff --git a/Tests/JExtractSwiftTests/JNI/JNITupleTests.swift b/Tests/JExtractSwiftTests/JNI/JNITupleTests.swift index 3e49daf08..58317feb2 100644 --- a/Tests/JExtractSwiftTests/JNI/JNITupleTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNITupleTests.swift @@ -57,9 +57,9 @@ struct JNITupleTests { """ let tupleResult$ = SwiftModule.returnPair() var element_0_jni$ = tupleResult$.0.getJNILocalRefValue(in: environment) - environment.interface.SetLongArrayRegion(environment, result_0$, 0, 1, &element_0_jni$) + environment.swiftInterface.SetLongArrayRegion(environment, result_0$, 0, 1, &element_0_jni$) let element_1_jni$ = tupleResult$.1.getJNILocalRefValue(in: environment) - environment.interface.SetObjectArrayElement(environment, result_1$, 0, element_1_jni$) + environment.swiftInterface.SetObjectArrayElement(environment, result_1$, 0, element_1_jni$) """ ] ) @@ -140,9 +140,9 @@ struct JNITupleTests { """ let tupleResult$ = SwiftModule.labeledTuple() var element_0_jni$ = tupleResult$.x.getJNILocalRefValue(in: environment) - environment.interface.SetIntArrayRegion(environment, result_0$, 0, 1, &element_0_jni$) + environment.swiftInterface.SetIntArrayRegion(environment, result_0$, 0, 1, &element_0_jni$) var element_1_jni$ = tupleResult$.y.getJNILocalRefValue(in: environment) - environment.interface.SetIntArrayRegion(environment, result_1$, 0, 1, &element_1_jni$) + environment.swiftInterface.SetIntArrayRegion(environment, result_1$, 0, 1, &element_1_jni$) """ ] ) @@ -202,7 +202,7 @@ struct JNITupleTests { detectChunkByInitialLines: 1, expectedChunks: [ """ - public func Java_com_example_swift_SwiftModule__00024singleTuple__Ljava_lang_String_2(environment: UnsafeMutablePointer!, thisClass: jclass, input: jstring?) -> jstring? { + public func Java_com_example_swift_SwiftModule__00024singleTuple__Ljava_lang_String_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, input: JNITypes.jstring?) -> JNITypes.jstring? { return SwiftModule.singleTuple(input: String(fromJNI: input, in: environment)).getJNILocalRefValue(in: environment) } """ diff --git a/Tests/JExtractSwiftTests/JNI/JNIVariablesTests.swift b/Tests/JExtractSwiftTests/JNI/JNIVariablesTests.swift index 45a4ed94f..794d74644 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIVariablesTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIVariablesTests.swift @@ -76,7 +76,7 @@ struct JNIVariablesTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyClass__00024getConstant__J") - public func Java_com_example_swift_MyClass__00024getConstant__J(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) -> jlong { + public func Java_com_example_swift_MyClass__00024getConstant__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong) -> jlong { ... return selfPointer$.pointee.constant.getJNILocalRefValue(in: environment) } @@ -135,7 +135,7 @@ struct JNIVariablesTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyClass__00024getMutable__J") - public func Java_com_example_swift_MyClass__00024getMutable__J(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) -> jlong { + public func Java_com_example_swift_MyClass__00024getMutable__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong) -> jlong { assert(selfPointer != 0, "selfPointer memory address was null") ... let selfPointer$ = UnsafeMutablePointer(bitPattern: selfPointerBits$) @@ -148,7 +148,7 @@ struct JNIVariablesTests { """, """ @_cdecl("Java_com_example_swift_MyClass__00024setMutable__JJ") - public func Java_com_example_swift_MyClass__00024setMutable__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, newValue: jlong, selfPointer: jlong) { + public func Java_com_example_swift_MyClass__00024setMutable__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, newValue: jlong, selfPointer: jlong) { assert(selfPointer != 0, "selfPointer memory address was null") ... selfPointer$.pointee.mutable = Int64(fromJNI: newValue, in: environment) @@ -194,7 +194,7 @@ struct JNIVariablesTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyClass__00024getComputed__J") - public func Java_com_example_swift_MyClass__00024getComputed__J(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) -> jlong { + public func Java_com_example_swift_MyClass__00024getComputed__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong) -> jlong { ... return selfPointer$.pointee.computed.getJNILocalRefValue(in: environment) } @@ -239,7 +239,7 @@ struct JNIVariablesTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyClass__00024getComputedThrowing__J") - public func Java_com_example_swift_MyClass__00024getComputedThrowing__J(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) -> jlong { + public func Java_com_example_swift_MyClass__00024getComputedThrowing__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong) -> jlong { ... do { return try selfPointer$.pointee.computedThrowing.getJNILocalRefValue(in: environment) @@ -303,14 +303,14 @@ struct JNIVariablesTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyClass__00024getGetterAndSetter__J") - public func Java_com_example_swift_MyClass__00024getGetterAndSetter__J(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) -> jlong { + public func Java_com_example_swift_MyClass__00024getGetterAndSetter__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong) -> jlong { ... return selfPointer$.pointee.getterAndSetter.getJNILocalRefValue(in: environment) } """, """ @_cdecl("Java_com_example_swift_MyClass__00024setGetterAndSetter__JJ") - public func Java_com_example_swift_MyClass__00024setGetterAndSetter__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, newValue: jlong, selfPointer: jlong) { + public func Java_com_example_swift_MyClass__00024setGetterAndSetter__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, newValue: jlong, selfPointer: jlong) { ... selfPointer$.pointee.getterAndSetter = Int64(fromJNI: newValue, in: environment) } @@ -369,14 +369,14 @@ struct JNIVariablesTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyClass__00024isSomeBoolean__J") - public func Java_com_example_swift_MyClass__00024isSomeBoolean__J(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) -> jboolean { + public func Java_com_example_swift_MyClass__00024isSomeBoolean__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong) -> jboolean { ... return selfPointer$.pointee.someBoolean.getJNILocalRefValue(in: environment) } """, """ @_cdecl("Java_com_example_swift_MyClass__00024setSomeBoolean__ZJ") - public func Java_com_example_swift_MyClass__00024setSomeBoolean__ZJ(environment: UnsafeMutablePointer!, thisClass: jclass, newValue: jboolean, selfPointer: jlong) { + public func Java_com_example_swift_MyClass__00024setSomeBoolean__ZJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, newValue: jboolean, selfPointer: jlong) { ... selfPointer$.pointee.someBoolean = Bool(fromJNI: newValue, in: environment) } @@ -435,14 +435,14 @@ struct JNIVariablesTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyClass__00024isBoolean__J") - public func Java_com_example_swift_MyClass__00024isBoolean__J(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) -> jboolean { + public func Java_com_example_swift_MyClass__00024isBoolean__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong) -> jboolean { ... return selfPointer$.pointee.isBoolean.getJNILocalRefValue(in: environment) } """, """ @_cdecl("Java_com_example_swift_MyClass__00024setBoolean__ZJ") - public func Java_com_example_swift_MyClass__00024setBoolean__ZJ(environment: UnsafeMutablePointer!, thisClass: jclass, newValue: jboolean, selfPointer: jlong) { + public func Java_com_example_swift_MyClass__00024setBoolean__ZJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, newValue: jboolean, selfPointer: jlong) { ... selfPointer$.pointee.isBoolean = Bool(fromJNI: newValue, in: environment) } @@ -491,7 +491,7 @@ struct JNIVariablesTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyClass__00024getPrivateSetCounter__J") - public func Java_com_example_swift_MyClass__00024getPrivateSetCounter__J(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) -> jlong { + public func Java_com_example_swift_MyClass__00024getPrivateSetCounter__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong) -> jlong { ... return selfPointer$.pointee.privateSetCounter.getJNILocalRefValue(in: environment) } diff --git a/Tests/JExtractSwiftTests/SpecializationTests.swift b/Tests/JExtractSwiftTests/SpecializationTests.swift index 41f99374b..b32707252 100644 --- a/Tests/JExtractSwiftTests/SpecializationTests.swift +++ b/Tests/JExtractSwiftTests/SpecializationTests.swift @@ -313,7 +313,7 @@ struct SpecializationTests { // FishBox constrained extension method: direct downcall with concrete type """ @_cdecl("Java_com_example_swift_FishBox__00024observeTheFish__JJ") - public func Java_com_example_swift_FishBox__00024observeTheFish__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong, selfTypePointer: jlong) { + public func Java_com_example_swift_FishBox__00024observeTheFish__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong, selfTypePointer: jlong) { assert(selfPointer != 0, "selfPointer memory address was null") let selfPointerBits$ = Int(Int64(fromJNI: selfPointer, in: environment)) let selfPointer$ = UnsafeMutablePointer(bitPattern: selfPointerBits$) @@ -326,7 +326,7 @@ struct SpecializationTests { // FishBox base method: also uses direct downcall (not opening protocols) """ @_cdecl("Java_com_example_swift_FishBox__00024count__JJ") - public func Java_com_example_swift_FishBox__00024count__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong, selfTypePointer: jlong) -> jlong { + public func Java_com_example_swift_FishBox__00024count__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong, selfTypePointer: jlong) -> jlong { assert(selfPointer != 0, "selfPointer memory address was null") let selfPointerBits$ = Int(Int64(fromJNI: selfPointer, in: environment)) let selfPointer$ = UnsafeMutablePointer(bitPattern: selfPointerBits$) diff --git a/Tests/JExtractSwiftTests/TimeIntervalTests.swift b/Tests/JExtractSwiftTests/TimeIntervalTests.swift index 6b8038a2f..d7b7f9116 100644 --- a/Tests/JExtractSwiftTests/TimeIntervalTests.swift +++ b/Tests/JExtractSwiftTests/TimeIntervalTests.swift @@ -34,7 +34,7 @@ struct TimeIntervalTests { [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024delay__D") - public func Java_com_example_swift_SwiftModule__00024delay__D(environment: UnsafeMutablePointer!, thisClass: jclass, seconds: jdouble) { + public func Java_com_example_swift_SwiftModule__00024delay__D(environment: JNIEnvironment!, thisClass: JNITypes.jclass, seconds: jdouble) { SwiftModule.delay(seconds: Double(fromJNI: seconds, in: environment)) } """ @@ -88,7 +88,7 @@ struct TimeIntervalTests { [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024now__") - public func Java_com_example_swift_SwiftModule__00024now__(environment: UnsafeMutablePointer!, thisClass: jclass) -> jdouble { + public func Java_com_example_swift_SwiftModule__00024now__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> jdouble { return SwiftModule.now() } """ diff --git a/Tests/JExtractSwiftTests/TypealiasResolutionTests.swift b/Tests/JExtractSwiftTests/TypealiasResolutionTests.swift index b0e9d5e56..e95ceb130 100644 --- a/Tests/JExtractSwiftTests/TypealiasResolutionTests.swift +++ b/Tests/JExtractSwiftTests/TypealiasResolutionTests.swift @@ -439,11 +439,11 @@ struct TypealiasResolutionTests { expectedChunks: [ #""" @_cdecl("Java_com_example_swift_Foo__00024getId__J") - public func Java_com_example_swift_Foo__00024getId__J(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) -> jlong { + public func Java_com_example_swift_Foo__00024getId__J(environment: JNIEnvironment!, thisClass: JNITypes.jclass, selfPointer: jlong) -> jlong { """#, #""" @_cdecl("Java_com_example_swift_Foo__00024setId__JJ") - public func Java_com_example_swift_Foo__00024setId__JJ(environment: UnsafeMutablePointer!, thisClass: jclass, newValue: jlong, selfPointer: jlong) { + public func Java_com_example_swift_Foo__00024setId__JJ(environment: JNIEnvironment!, thisClass: JNITypes.jclass, newValue: jlong, selfPointer: jlong) { """#, ], ) diff --git a/Tests/JExtractSwiftTests/UUIDTests.swift b/Tests/JExtractSwiftTests/UUIDTests.swift index 1fa3fdfbb..e38283651 100644 --- a/Tests/JExtractSwiftTests/UUIDTests.swift +++ b/Tests/JExtractSwiftTests/UUIDTests.swift @@ -34,7 +34,7 @@ struct UUIDTests { [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024acceptUUID__Ljava_lang_String_2") - public func Java_com_example_swift_SwiftModule__00024acceptUUID__Ljava_lang_String_2(environment: UnsafeMutablePointer!, thisClass: jclass, uuid: jstring?) { + public func Java_com_example_swift_SwiftModule__00024acceptUUID__Ljava_lang_String_2(environment: JNIEnvironment!, thisClass: JNITypes.jclass, uuid: JNITypes.jstring?) { let uuid_string$ = String(fromJNI: uuid, in: environment) guard let uuid_unwrapped$ = UUID.init(uuidString: uuid_string$) else { fatalError("Invalid UUID string passed from Java: \\(uuid_string$)") @@ -92,7 +92,7 @@ struct UUIDTests { [ """ @_cdecl("Java_com_example_swift_SwiftModule__00024returnUUID__") - public func Java_com_example_swift_SwiftModule__00024returnUUID__(environment: UnsafeMutablePointer!, thisClass: jclass) -> jstring? { + public func Java_com_example_swift_SwiftModule__00024returnUUID__(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> JNITypes.jstring? { return SwiftModule.returnUUID().uuidString.getJNILocalRefValue(in: environment) } """ diff --git a/Tests/SwiftJavaMacrosTests/JavaImplementationMacroTests.swift b/Tests/SwiftJavaMacrosTests/JavaImplementationMacroTests.swift index 7ff77bc57..82f83c36e 100644 --- a/Tests/SwiftJavaMacrosTests/JavaImplementationMacroTests.swift +++ b/Tests/SwiftJavaMacrosTests/JavaImplementationMacroTests.swift @@ -48,7 +48,7 @@ class JavaImplementationMacroTests: XCTestCase { @used #endif @_cdecl("Java_org_swift_example_Hello_1World_test_1method") - public func __macro_local_22HelloWorld_test_methodfMu_(environment: UnsafeMutablePointer!, thisObj: jobject) -> Int32.JNIType { + public func __macro_local_22HelloWorld_test_methodfMu_(environment: JNIEnvironment!, thisObj: JNITypes.jobject) -> Int32.JNIType { let obj = HelloWorld(javaThis: thisObj, environment: environment!) return obj.test_method() .getJNILocalRefValue(in: environment) @@ -81,7 +81,7 @@ class JavaImplementationMacroTests: XCTestCase { @used #endif @_cdecl("Java_com_example_test_MyClass_simpleMethod") - public func __macro_local_20MyClass_simpleMethodfMu_(environment: UnsafeMutablePointer!, thisObj: jobject) -> Int32.JNIType { + public func __macro_local_20MyClass_simpleMethodfMu_(environment: JNIEnvironment!, thisObj: JNITypes.jobject) -> Int32.JNIType { let obj = MyClass(javaThis: thisObj, environment: environment!) return obj.simpleMethod() .getJNILocalRefValue(in: environment) @@ -114,7 +114,7 @@ class JavaImplementationMacroTests: XCTestCase { @used #endif @_cdecl("Java_org_example_Utils_static_1helper") - public func __macro_local_19Utils_static_helperfMu_(environment: UnsafeMutablePointer!, thisClass: jclass) -> String.JNIType { + public func __macro_local_19Utils_static_helperfMu_(environment: JNIEnvironment!, thisClass: JNITypes.jclass) -> String.JNIType { return Utils.static_helper(environment: environment) .getJNILocalRefValue(in: environment) } @@ -154,7 +154,7 @@ class JavaImplementationMacroTests: XCTestCase { @used #endif @_cdecl("Java_test_Class_1With_1Underscores_method_1one") - public func __macro_local_31ClassWithUnderscores_method_onefMu_(environment: UnsafeMutablePointer!, thisObj: jobject) -> Int32.JNIType { + public func __macro_local_31ClassWithUnderscores_method_onefMu_(environment: JNIEnvironment!, thisObj: JNITypes.jobject) -> Int32.JNIType { let obj = ClassWithUnderscores(javaThis: thisObj, environment: environment!) return obj.method_one() .getJNILocalRefValue(in: environment) @@ -164,7 +164,7 @@ class JavaImplementationMacroTests: XCTestCase { @used #endif @_cdecl("Java_test_Class_1With_1Underscores_method_1two") - public func __macro_local_31ClassWithUnderscores_method_twofMu_(environment: UnsafeMutablePointer!, thisObj: jobject) -> Int32.JNIType { + public func __macro_local_31ClassWithUnderscores_method_twofMu_(environment: JNIEnvironment!, thisObj: JNITypes.jobject) -> Int32.JNIType { let obj = ClassWithUnderscores(javaThis: thisObj, environment: environment!) return obj.method_two() .getJNILocalRefValue(in: environment) @@ -205,7 +205,7 @@ class JavaImplementationMacroTests: XCTestCase { @used #endif @_cdecl("Java_org_swift_swiftkit_core_collections_SwiftDictionaryMap__00024size") - public func __macro_local_28SwiftDictionaryMapJava__sizefMu_(environment: UnsafeMutablePointer!, thisClass: jclass, pointer: Int64.JNIType) -> Int32.JNIType { + public func __macro_local_28SwiftDictionaryMapJava__sizefMu_(environment: JNIEnvironment!, thisClass: JNITypes.jclass, pointer: Int64.JNIType) -> Int32.JNIType { return SwiftDictionaryMapJava._size(environment: environment, pointer: Int64(fromJNI: pointer, in: environment!)) .getJNILocalRefValue(in: environment) } @@ -214,7 +214,7 @@ class JavaImplementationMacroTests: XCTestCase { @used #endif @_cdecl("Java_org_swift_swiftkit_core_collections_SwiftDictionaryMap__00024destroy") - public func __macro_local_31SwiftDictionaryMapJava__destroyfMu_(environment: UnsafeMutablePointer!, thisClass: jclass, pointer: Int64.JNIType) { + public func __macro_local_31SwiftDictionaryMapJava__destroyfMu_(environment: JNIEnvironment!, thisClass: JNITypes.jclass, pointer: Int64.JNIType) { return SwiftDictionaryMapJava._destroy(environment: environment, pointer: Int64(fromJNI: pointer, in: environment!)) } """, @@ -245,7 +245,7 @@ class JavaImplementationMacroTests: XCTestCase { @used #endif @_cdecl("Java_org_example_Processor_process_1data") - public func __macro_local_22Processor_process_datafMu_(environment: UnsafeMutablePointer!, thisObj: jobject) { + public func __macro_local_22Processor_process_datafMu_(environment: JNIEnvironment!, thisObj: JNITypes.jobject) { let obj = Processor(javaThis: thisObj, environment: environment!) return obj.process_data() }