Does Android ART support runtime dynamic class loa

2019-01-25 05:48发布

Currently, it's possible to dynamically load .dex classfiles into Android's Dalvik VM. This could probably also be used for dynamic code generation at runtime.

Is this still possible with the upcoming ART runtime?

1条回答
叼着烟拽天下
2楼-- · 2019-01-25 06:14

It seems to work just like it did with Dalvik.

Thanks to matiash for referencing the I/O 2014 talk! 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.

[...]

[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. So Dalvik never had supports for the kind of doing end memory injection of instructions, and so on.

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.

查看更多
登录 后发表回答