Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ extension JNISwift2JavaGenerator {
printer.print("environment = try! JavaVirtualMachine.shared().environment()")
let inner = nativeFunctionSignature.result.conversion.render(&printer, "swiftResult$")
if swiftFunctionResultType.isVoid {
printer.print("environment.interface.CallBooleanMethodA(environment, globalFuture, \(completeMethodID), [jvalue(l: nil)])")
printer.print("_ = environment.interface.CallBooleanMethodA(environment, globalFuture, \(completeMethodID), [jvalue(l: nil)])")
} else {
let result: String
if nativeFunctionSignature.result.javaType.requiresBoxing {
Expand All @@ -1047,7 +1047,7 @@ extension JNISwift2JavaGenerator {
result = inner
}

printer.print("environment.interface.CallBooleanMethodA(environment, globalFuture, \(completeMethodID), [jvalue(l: \(result))])")
printer.print("_ = environment.interface.CallBooleanMethodA(environment, globalFuture, \(completeMethodID), [jvalue(l: \(result))])")
}
}

Expand All @@ -1069,7 +1069,7 @@ extension JNISwift2JavaGenerator {
"""
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)])
_ = catchEnvironment.interface.CallBooleanMethodA(catchEnvironment, globalFuture, \(completeExceptionallyMethodID), [jvalue(l: exception)])
"""
)
}
Expand Down Expand Up @@ -1111,4 +1111,4 @@ extension JNISwift2JavaGenerator {
}
}
}
}
}
26 changes: 13 additions & 13 deletions Tests/JExtractSwiftTests/JNI/JNIAsyncTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct JNIAsyncTests {
}
let swiftResult$ = await SwiftModule.asyncVoid()
environment = try! JavaVirtualMachine.shared().environment()
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)])
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)])
}
}
#endif
Expand All @@ -84,7 +84,7 @@ struct JNIAsyncTests {
}
let swiftResult$ = await SwiftModule.asyncVoid()
environment = try! JavaVirtualMachine.shared().environment()
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)])
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)])
}
}
}
Expand Down Expand Up @@ -146,12 +146,12 @@ struct JNIAsyncTests {
do {
let swiftResult$ = await try SwiftModule.async()
environment = try! JavaVirtualMachine.shared().environment()
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)])
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: 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)])
_ = catchEnvironment.interface.CallBooleanMethodA(catchEnvironment, globalFuture, _JNIMethodIDCache.CompletableFuture.completeExceptionally, [jvalue(l: exception)])
}
}
}
Expand All @@ -166,12 +166,12 @@ struct JNIAsyncTests {
do {
let swiftResult$ = await try SwiftModule.async()
environment = try! JavaVirtualMachine.shared().environment()
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)])
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: 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)])
_ = catchEnvironment.interface.CallBooleanMethodA(catchEnvironment, globalFuture, _JNIMethodIDCache.CompletableFuture.completeExceptionally, [jvalue(l: exception)])
}
}
}
Expand Down Expand Up @@ -234,7 +234,7 @@ struct JNIAsyncTests {
let swiftResult$ = await SwiftModule.async(i: Int64(fromJNI: i, in: environment))
environment = try! JavaVirtualMachine.shared().environment()
let boxedResult$ = SwiftJavaRuntimeSupport._JNIBoxedConversions.box(swiftResult$.getJNIValue(in: environment), in: environment)
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)])
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)])
}
}
#endif // end of swift(>=6.2)
Expand All @@ -248,7 +248,7 @@ struct JNIAsyncTests {
let swiftResult$ = await SwiftModule.async(i: Int64(fromJNI: i, in: environment))
environment = try! JavaVirtualMachine.shared().environment()
let boxedResult$ = SwiftJavaRuntimeSupport._JNIBoxedConversions.box(swiftResult$.getJNIValue(in: environment), in: environment)
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)])
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)])
}
}
return
Expand Down Expand Up @@ -328,7 +328,7 @@ struct JNIAsyncTests {
result$.initialize(to: swiftResult$)
let resultBits$ = Int64(Int(bitPattern: result$))
let boxedResult$ = SwiftJavaRuntimeSupport._JNIBoxedConversions.box(resultBits$.getJNIValue(in: environment), in: environment)
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)])
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)])
}
}
#endif
Expand All @@ -345,7 +345,7 @@ struct JNIAsyncTests {
result$.initialize(to: swiftResult$)
let resultBits$ = Int64(Int(bitPattern: result$))
let boxedResult$ = SwiftJavaRuntimeSupport._JNIBoxedConversions.box(resultBits$.getJNIValue(in: environment), in: environment)
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)])
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)])
}
}
return
Expand Down Expand Up @@ -402,7 +402,7 @@ struct JNIAsyncTests {
deferEnvironment.interface.DeleteGlobalRef(deferEnvironment, s)
}
...
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: swiftResult$.getJNIValue(in: environment))])
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: swiftResult$.getJNIValue(in: environment))])
...
}
"""
Expand Down Expand Up @@ -463,11 +463,11 @@ struct JNIAsyncTests {
...
var task: Task<Void, Never>? = nil
...
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.SimpleCompletableFuture.complete, [jvalue(l: boxedResult$)])
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.SimpleCompletableFuture.complete, [jvalue(l: boxedResult$)])
...
}
"""
]
)
}
}
}
Loading