3 ms·
> Java is memory safe, and classloaders have been used since forever to sandbox applications (remember applets?). Well, except that Android allows apps to run
by comex 15y ago
> Java is memory safe, and classloaders have been used since forever to sandbox applications (remember applets?).
Well, except that Android allows apps to run arbitrary native code using the NDK.
- inoop 15y ago> Well, except that Android allows apps to run arbitrary native code using the NDK. I was under the assumption that they can support native code because of the way they designed Android, not the other way around. I highly doubt that supporting native code was the design rationale here. I think they just designed Dalvik to use Linux threads and assume it to run inside its own process. That certainly makes things much simpler for the VM. The fact that you can safely load native code follows naturally. Still, supporting native code does not have to dictate how you ensure memory protection, or whether each app has to run inside its own process. You can always run a native library (i.e. a video codec) inside a separate process and use memory-safe communication with the process that runs the Java app. You can also go the NACL route. There's absolutely no reason why supporting native code would result in a choppy UI on Android.
- daniel_solano 15y agoYes, you can run arbitrary code using the NDK, but you're still sand-boxed into your application's process. Android relies on the Linux security model where each app runs in its own process as its own user. As such, just like with a Linux application, you'd have to find some sort of privilege escalation exploit before you can start mucking around at will.