是否有可能从本地code使用Dalvik虚拟机
我希望能够在Android中使用本地code为目标的Dalvik虚拟机。
这意味着使用在Android的下库源平台/ Dalvik的列出本机类。
I'd like to be able to target the Dalvik VM using native code in Android. This means using native classes that are listed in platform/dalvik under android sources repositories.
在我特别想打电话 Sync.dvmLockObject
及其对应 Sync.dvmUnlockObject
。
In particular, i'd like to call Sync.dvmLockObject
and its counterpart Sync.dvmUnlockObject
.
这可能吗?你能否提供code的快速片段,或特定库的说明包括哪些内容?
Is it possible ? Could you provide a quick snippet of code, or instructions for particular libraries to include ?
的另外,你可以提供一个Java或本地code替代,做同样的(即能够访问Java对象的监视器。使用的pthread
例如似乎并没有拨到为例)。的
Alternatively, you can provide a java, or native code alternative that does the same (that is, be able to access a java object's monitor. Using pthread
for example doesn't seem to be appropriated for example).
您可以使用JNI的的findClass()找到任何私有类的框架,并找到并调用其方法通常JNI的方式。但 dvmLockObject()是不是方法同步
类。这是Dalvik的本地库的一部分。你可以把它从您的code通常C函数。您将链接到 libdvm.so
,因为其他任何系统库。
You can use JNI FindClass() to find any private class of the framework, and find and call its methods the usual JNI way. But dvmLockObject() is not a method of Sync
class. It is part of the dalvik native libraries. You can call it as a usual C function from your code. You will link to libdvm.so
, as to any other system library.
但我不知道有什么用处也可以在调用这个函数。
But I don't know what useful purpose there can be in calling this function.