Skip to content
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

High level C++ bindings for JNI calls #1314

Open
pjmlp opened this issue Jul 11, 2020 · 12 comments
Open

High level C++ bindings for JNI calls #1314

pjmlp opened this issue Jul 11, 2020 · 12 comments

Comments

@pjmlp
Copy link

pjmlp commented Jul 11, 2020

As discussed on Reddit, here is an improvement idea.

Either adopt one of the following C++ JNI libraries:

Or having a Google provided one that takes advantage of templates and compile time programming to wrap JNI calls into C++ type safe calls, without the low level strings, similar to the approaches taken by the libraries above.

@DanAlbert
Copy link
Member

https://android.googlesource.com/platform/libnativehelper/ is the one we use in AOSP, so most likely path is to use that. Will definitely have a look at the others to see what we're missing, if anything.

@alexcohn
Copy link

@pjmlp could you share the Reddit?

@DanAlbert
Copy link
Member

From the AMA last week: https://www.reddit.com/r/androiddev/comments/hk3hrq/_/fxkkk6l

@alexcohn
Copy link

alexcohn commented Dec 8, 2020

@mgood7123 what is destroyJvm ?

@mgood7123
Copy link

@mgood7123 what is destroyJvm ?

ummm just ignore that

@wang-bin
Copy link

https://github.com/wang-bin/JMI

I use it in my projects. The api is simple to use.

@cpsauer
Copy link

cpsauer commented Nov 18, 2022

If useful (and since not mentioned here), after reviewing the available options, we found fbjni to be quite good for the Android JNI use case, with helper code on both sides of the language boundary. It's already widely used and tested in, e.g. React Native and PyTorch.

That said (if this becomes and NDK priority), they could definitely use some help and NDK guidance, particularly around libc++. Could be a good partnership opportunity!

(It seemed like one barrier to libnativehelper was that it depended on some other private libraries?)

@DanAlbert
Copy link
Member

There's already a CL up that adds libnativehelper to androidx. It's blocked on some infrastructure problems that won't be resolved soon, but the work is largely done.

@cpsauer
Copy link

cpsauer commented Nov 23, 2022

Oh, cool! Thanks for letting us know. Any chance there's a public link where we can follow the progress? (Maybe that's here.)

(I'm also curious what the infra blockers are!)

@cpsauer
Copy link

cpsauer commented Nov 23, 2022

If it's still a goal to look at other efforts to see if there are any goodies to bring in, I'd be way curious what you Googlers think of fbjni! (Last I checked, it seemed like it might have some additional good ideas.)

@DanAlbert
Copy link
Member

DanAlbert commented Nov 28, 2022

Any chance there's a public link where we can follow the progress?

Not really. https://android-review.googlesource.com/c/platform/frameworks/support/+/2089324 is the CL, but there isn't any ongoing conversation anywhere, and I assume that's what you're looking for.

(I'm also curious what the infra blockers are!)

externalNativeBuild can't do remote caching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants