-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: try out golang.org/x/mobile for generating Java JNI bindings #1327
Conversation
Codecov Report
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #1327 +/- ##
=======================================
Coverage 89.02% 89.02%
=======================================
Files 75 75
Lines 7689 7689
=======================================
Hits 6845 6845
Misses 502 502
Partials 342 342 |
can i get to hop on this @adamdecaf ? |
Yea go for it! |
I am trying to get a clear description of this very PR. What we are trying to achieve here it to use Also, I just ran the two
Was this the main problem you faced while working on it. I am just trying to get the state of the PR and what needs to be achieved. |
Yes that's pretty much where I ended up as well. Java is a popular language so if we could offer native support (without having to rewrite Go to Java) that would help a lot of potential users of the library. We probably have to write some middleware to convert functions like SegmentFile so they're compatible with Java / JNI. The Java interface would have a slightly different API than Go, but would be largely compatible. |
Yes, that’s the constraint. Not sure I understand how exactly the middleware should be built. If you can shed more light to that But the temporary thing I did was to duplicate the functions (SegmentFileJNI and NextEntryJNI) and now embed the return values in a single struct to align with gobind restrictions. It worked and generated successfully but the problem is that there is no way to ignore the normal function or suppress the errors from the normal functions during the bindings. |
I think we will want to create a new package which calls functions from moov-io/ach but returns a struct of the multiple values like you did. That way we generate a single package and avoid trying to generate known bad code. |
package javainterop
type EntryDetail ach.EntryDetail // reference every type
type File ach.File
type SegmentFileResponse struct {
CreditEntryFile *File
DebitEntryFile *File
}
func (f *File) SegmentFile(_ *SegmentFileConfiguration) (SegmentFileResponse, error) Ideally I'd like to generate this or at least compare the API surface between moov-io/ach and the javainterop package so we can ensure every function is ported over. |
Alright I will work on that. |
https://docs.google.com/document/d/1y9hStonl9wpj-5VM-xWrSTuEJFUAxGOXOhxvAs7GZHE/edit
See: https://blog.dogan.io/2015/08/15/java-jni-jnr-go/
See: https://pkg.go.dev/golang.org/x/mobile/cmd/gobind
Related: golang/go#34885
Remaining Items
Notes