是否有可能从本地code使用Dalvik虚拟机 [英] Is it possible to access Dalvik VM from native code

查看:161
本文介绍了是否有可能从本地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.

这篇关于是否有可能从本地code使用Dalvik虚拟机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆