java - Android: javac vs Dalvik -


my understanding google didn't oracle's licensing policy using jre in java me rewrote using own jvm specification mimics jre behaves little bit differently, when comes making things more efficient , more secure.

so, if understanding correct, means when javac ran on java source code , compiled "binary" byetcode, compliant jvm interpret bytecode different dalvik (in cases). inherent difference between dalvik , other (compliant) jvms.

if have said far incorrect, please begin correcting me!

now, if android came own compiler (which might), , compiled java source in different (dalvik-compliant) manner javac, understand how code (not compiled android sdk) not run on android device:

mysource.java --> javac --> mysource.class (jre-compliant) --> jvm --> running java app mysource.java --> android-compiler --> mysource.class (dalvik-compliant) --> dalvik jvm --> running android app 

however, looks use javac compile android apps!?!? looks have this:

mysource.java --> javac --> mysource.class (jre-compliant) --> jvm --> running java app mysource.java --> javac --> mysource.class (jre-compliant) --> dalvik jvm --> running android app (???) 

if javac used compile sources bytecode, why dalvik can't run types of java code?

i asked similar question yesterday , although technically answered (after re-reading question see not specific enough) no 1 able explain that's inherent dalvik makes impossible run java code projects google guice or apache camel. told in order camel run on dalvik, have camel's source , have "built android sdk", couldn't clarity on meant or implied.

with camel, instance, have (simplified):

routebuilder.java --> javac --> routebuilder.class --> jartool --> camel-context-2.9.jar --> jvm --> running camel esb routebuilder.java --> javac --> routebuilder.class --> jartool --> camel-context-2.9.jar --> dalvik jvm --> doesn't work !!! (???) 

clearly, happening inside dalvik jvm prevents running types of java code. i'm trying understand types of java code not run when "fed" dalvik jvm.

edit: in before "but camel 3.0 run on android!" know - not question!

i'm trying understand types of java code not run when "fed" dalvik jvm. 

dalvik jvm differs other jvms in following aspects:

  • it uses special dex format storing applications binaries vs. jar , pack200 formats used standard java virtual machines. google claims dex results in smaller binaries jar. think use pack200 same success, decided go own way in aspect

  • dalvik jvm optimized running multiple jvm processes simultaneously

  • dalvik jvm uses register-based architecture vs. stack based architecture of other jvms intent speed execution , reduce binary sizes

  • it uses own instructions set (not standard jvm bytecode)

  • one can run (if needed) several independent android applications within single jvm process

  • application execution can span across several dalvik jvm processes “naturally”. support adds:

    • special object serialization mechanism based on parcel , parcelable classes. functionally serves same purpose standard java serializable, results in smaller data footprint , potentially more lenient towards differences in versions of classes

    • special android way execute inter process calls (ipc) based on android interface definition language (aidl)

  • until android 2.2 dalvik jvm did not support jit compilation adversely impacted android application performance. adding in 2.2 improves markedly execution speed used applications


Comments