Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. This could probably also be used for dynamic code generation at runtime.

Is this still possible with the upcoming ART runtime?

like image 235
lxgr Avatar asked May 19 '14 13:05

lxgr


People also ask

Which runtime is better Dalvik or ART?

Android Runtime, or ART, offers a faster alternative; Dalvik is optimized to run on older hardware with a limited processor and memory, something that isn't required of modern Android hardware. With Dalvik, apps are compiled using the Just-In-Time (JIT) compiler, making use of free system resources.

Does Android use Dalvik?

Dalvik is a discontinued process virtual machine (VM) in Android operating system that executes applications written for Android. (Dalvik bytecode format is still used as a distribution format, but no longer at runtime in newer Android versions.)

What is used instead of Dalvik?

So, from Android 4.4(Kitkat) ART was introduced as runtime and finally from Android 5.0(Lollipop), the Dalvik was completely replaced by ART by Android.


1 Answers

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.

like image 79
lxgr Avatar answered Sep 20 '22 03:09

lxgr