简体   繁体   English

Android ART是否像Dalvik一样支持运行时动态类加载?

[英]Does Android ART support runtime dynamic class loading just like Dalvik?

Currently, it's possible to dynamically load .dex classfiles into Android's Dalvik VM. 目前, 可以.dex类文件动态加载到Android的Dalvik VM中。 This could probably also be used for dynamic code generation at runtime . 这可能也可用于在运行时生成动态代码

Is this still possible with the upcoming ART runtime ? 即将到来的ART运行时间仍然可以实现吗?

It seems to work just like it did with Dalvik. 它似乎像Dalvik一样工作。

Thanks to matiash for referencing the I/O 2014 talk! 感谢matiash引用I / O 2014演讲! I've watched the video recording of it, and here is what the developers have to say on runtime code loading (taken from the transcript): 我已经看过它的视频录制 ,这是开发人员在运行时代码加载时所说的内容(取自成绩单):

[Question from the audience:] So I was wondering how ART is going to jive[?] with byte code injection that might happen right after compilation or even at runtime. [来自观众的问题:]所以我想知道ART是如何使用字节代码注入来生成[?],这可能在编译之后甚至在运行时发生。

[...] [...]

[Answer by Ian Rogers:] So the model that Dalvik has and ART continues is that for class loaders, we have to have everything that the class loader has backed up by a file. [Ian Rogers的回答:]所以Dalvik的模型和ART的继续是,对于类加载器,我们必须拥有类加载器由文件备份的所有内容。 So Dalvik never had supports for the kind of doing end memory injection of instructions, and so on. 所以Dalvik从来没有支持那种做内存注入指令的工作,等等。

If you have a file on the disk, then this is something we can do ahead of time compilation for and put into our cache so that we're not regenerating it all of the time. 如果磁盘上有一个文件,那么我们可以提前编译并放入缓存中,这样我们就不会一直重新生成它。 So basically, it works the same way as with Dalvik. 所以基本上,它的工作方式与Dalvik相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM