swiftlang / swiftlang/swift-java

JNI async thunk generates empty jvalue(l: ) for generic result

Open
#752 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
1.2k
Forks
123
Avg merge
1d 7h
Merged PRs (30d)
16

Description

It seems to happen for an async method. I am not sure what the correct fix should be here. If this combination of async JNI bindings and generic results is not supported yet, maybe the generator should treat such methods as unsupported and skip them 🤷🏻‍♂️

/cust-wallet-core/.build/plugins/outputs/cust-wallet-core/CustWalletCore/destination/JExtractSwiftPlugin/Sources/QuickNodeApiTarget+SwiftJava.swift:71:130: error: cannot find 'jvalue(l:)' in scope
 69 |             environment.interface.SetLongField(environment, resultOut, _JNIMethodIDCache._OutSwiftGenericInstance.selfTypePointer, metadataPointerBits$.getJNIValue(in: environment))
 70 |           } // render(_:_:) @ JExtractSwiftLib/JNISwift2JavaGenerator+NativeTranslation.swift:1638
 71 |           _ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: )])
    |                                                                                                                                  `- error: cannot find 'jvalue(l:)' in scope
 72 |         } // printTaskBody(printer:) @ JExtractSwiftLib/JNISwift2JavaGenerator+NativeTranslation.swift:1799
 73 |         catch {

/cust-wallet-core/.build/plugins/outputs/cust-wallet-core/CustWalletCore/destination/JExtractSwiftPlugin/Sources/QuickNodeApiTarget+SwiftJava.swift:106:128: error: cannot find 'jvalue(l:)' in scope
104 |           environment.interface.SetLongField(environment, resultOut, _JNIMethodIDCache._OutSwiftGenericInstance.selfTypePointer, metadataPointerBits$.getJNIValue(in: environment))
105 |         } // render(_:_:) @ JExtractSwiftLib/JNISwift2JavaGenerator+NativeTranslation.swift:1638
106 |         _ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: )])
    |                                                                                                                                `- error: cannot find 'jvalue(l:)' in scope
107 |       } // printTaskBody(printer:) @ JExtractSwiftLib/JNISwift2JavaGenerator+NativeTranslation.swift:1799
108 |       catch {

/cust-wallet-core/.build/plugins/outputs/cust-wallet-core/CustWalletCore/destination/JExtractSwiftPlugin/Sources/QuickNodeApiTarget+SwiftJava.swift:163:130: error: cannot find 'jvalue(l:)' in scope
161 |             environment.interface.SetLongField(environment, resultOut, _JNIMethodIDCache._OutSwiftGenericInstance.selfTypePointer, metadataPointerBits$.getJNIValue(in: environment))
162 |           } // render(_:_:) @ JExtractSwiftLib/JNISwift2JavaGenerator+NativeTranslation.swift:1638
163 |           _ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: )])
    |                                                                                                                                  `- error: cannot find 'jvalue(l:)' in scope
164 |         } // printTaskBody(printer:) @ JExtractSwiftLib/JNISwift2JavaGenerator+NativeTranslation.swift:1799
165 |         catch {

/cust-wallet-core/.build/plugins/outputs/cust-wallet-core/CustWalletCore/destination/JExtractSwiftPlugin/Sources/QuickNodeApiTarget+SwiftJava.swift:198:128: error: cannot find 'jvalue(l:)' in scope
196 |           environment.interface.SetLongField(environment, resultOut, _JNIMethodIDCache._OutSwiftGenericInstance.selfTypePointer, metadataPointerBits$.getJNIValue(in: environment))
197 |         } // render(_:_:) @ JExtractSwiftLib/JNISwift2JavaGenerator+NativeTranslation.swift:1638
198 |         _ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: )])
    |                                                                                                                                `- error: cannot find 'jvalue(l:)' in scope
199 |       } // printTaskBody(printer:) @ JExtractSwiftLib/JNISwift2JavaGenerator+NativeTranslation.swift:1799
200 |       catch {

> Task :buildSwiftArmeabi-v7a FAILED

One of the Swift signatures that I suspect triggered this generated-code issue is:

public func sendRawTransaction(
  hexstring: String,
  maxfeerate: Double = 0.10
) async throws -> QuickNodeApi.RawResponse<QuickNodeApi.Sendrawtransaction>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in JNISwift2JavaGenerator+NativeTranslation.swift around render(::) at line 1638 and printTaskBody(printer:) at line 1799, using the async sendRawTransaction signature as a reproduction. Check how generic results are translated for CompletableFuture completion; done means the generated Swift compiles without an empty jvalue(l: ) or explicitly rejects unsupported combinations.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, swift
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.