Re: Issue calling JNI_GetCreatedJavaVMs in native code

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Issue calling JNI_GetCreatedJavaVMs in native code

Karl Semich
To follow up a decade later,

On Thursday, January 14, 2010 at 7:06:22 PM UTC-5 Digit wrote:
jint JNI_GetDefaultJavaVMInitArgs(void*);
jint JNI_CreateJavaVM(JavaVM**, JNIEnv**, void*);
jint JNI_GetCreatedJavaVMs(JavaVM**, jsize, jsize*);

and we do not support application code linking to them.

The reason is that a reference to libdvm.so would embedded in the corresponding
generated shared library, and the code would become unloadable the day we rename
the library (e.g. libdvmJit.so + libdvmInt.so or whatever).

If you *really* need to use these, you should hunt for /system/lib/libvdm.so with dlopen()
and find the symbol addresses with dlsym(), and be prepared to fail nicely if nothing is
found at the usual address.

I tried doing this, and the symbol does load, but the resulting JNI_GetCreatedJavaVMs() is returning a completely empty array for me.   It's unfortunate that when porting libraries to android we have to alter the interface to let the user pass in a JNIEnv pointer, if android java functionality is used in the port.

I have not tried creating a new VM at this time.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/5907d1ba-26e8-4af8-a67c-ad3cc632f33fn%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Issue calling JNI_GetCreatedJavaVMs in native code

Karl Semich
Here's the up-to-date information: https://github.com/android/ndk/issues/1320

On 2/12/21, Karl Semich <[hidden email]> wrote:

> To follow up a decade later,
>
> On Thursday, January 14, 2010 at 7:06:22 PM UTC-5 Digit wrote:
>
>> jint JNI_GetDefaultJavaVMInitArgs(void*);
>> jint JNI_CreateJavaVM(JavaVM**, JNIEnv**, void*);
>> jint JNI_GetCreatedJavaVMs(JavaVM**, jsize, jsize*);
>>
>> and we do not support application code linking to them.
>>
>> The reason is that a reference to libdvm.so would embedded in the
>> corresponding
>> generated shared library, and the code would become unloadable the day we
>>
>> rename
>> the library (e.g. libdvmJit.so + libdvmInt.so or whatever).
>>
>> If you *really* need to use these, you should hunt for
>> /system/lib/libvdm.so with dlopen()
>> and find the symbol addresses with dlsym(), and be prepared to fail nicely
>>
>> if nothing is
>> found at the usual address.
>>
>
> I tried doing this, and the symbol does load, but the resulting
> JNI_GetCreatedJavaVMs() is returning a completely empty array for me.
>  It's unfortunate that when porting libraries to android we have to alter
> the interface to let the user pass in a JNIEnv pointer, if android java
> functionality is used in the port.
>
> I have not tried creating a new VM at this time.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "android-ndk" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/android-ndk/IVvYWu4CNIY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [hidden email].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/android-ndk/5907d1ba-26e8-4af8-a67c-ad3cc632f33fn%40googlegroups.com.
>

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CALL-%3De629Y86ZkbTE%2B%2B9SJ9ujkZiWb%3Df%3DGEim1HLeG-BxOU1NQ%40mail.gmail.com.