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

x/mobile: make RunOnJVM available #26815

Closed
hajimehoshi opened this issue Aug 5, 2018 · 7 comments

Comments

Projects
None yet
6 participants
@hajimehoshi
Copy link
Contributor

commented Aug 5, 2018

Before golang/mobile@56e3592, I was able to use an exported variable current_vm and current_ctx and call JNI functions. However, as these variables are no longer exported, it is impossible to access JNI functions. I admit accessing current_vm was not a good manner, but we rely on JNI functions heavily so we'd be really glad if RunOnJVM could be available (again?).

For iOS, Objective-C functions are available via cgo, so there is no problem.

CC @eliasnaur

@gopherbot gopherbot added this to the Unreleased milestone Aug 5, 2018

@gopherbot gopherbot added the mobile label Aug 5, 2018

@eliasnaur

This comment has been minimized.

Copy link
Contributor

commented Aug 5, 2018

What is your use case? If you have any kind of Java code in your app, you can call into C through JNI and attain a JNIEnv pointer (and through that, a JavaVM pointer) that way.

@hajimehoshi

This comment has been minimized.

Copy link
Contributor Author

commented Aug 5, 2018

https://github.com/hajimehoshi/ebiten/blob/master/internal/devicescale/impl_android.go Actual usecase to call getResources().getDisplayMetrics().density in Java.

To call JNI functions, JavaVM*, JNIEnv*, and context values are required, but how can I get them via Cgo? That library doesn't have any Java code so that I can use the lib with gomobile build.

@gopherbot

This comment has been minimized.

Copy link

commented Aug 5, 2018

Change https://golang.org/cl/127758 mentions this issue: app: add RunOnJVM to allow Cgo access to the Android JVM and context

@eliasnaur

This comment has been minimized.

Copy link
Contributor

commented Aug 5, 2018

Is CL 127758 enough to solve your issue?

@hajimehoshi

This comment has been minimized.

Copy link
Contributor Author

commented Aug 5, 2018

Yes, this would solve our problems perfectly!

@ALTree ALTree changed the title x/mobile: proposal: make RunOnJVM available x/mobile: make RunOnJVM available Aug 5, 2018

@ALTree ALTree added the NeedsDecision label Aug 5, 2018

@ntop001

This comment has been minimized.

Copy link

commented Aug 11, 2018

@eliasnaur Great! I'm porting a game to Android, too. JNI interface is heavily used in my App. With RunOnJVM we can implement most of the Android functions.

@xfxdev

This comment has been minimized.

Copy link

commented Mar 25, 2019

@eliasnaur this is only available for app, not for gobind libraries:(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.