You are on page 1of 2

Running Java bytecode on the Android - Sun JVM on top of DalvikVM -...

http://stackoverflow.com/questions/670987/running-java-bytecode-on-t...

Running Java bytecode on the Android - Sun JVM on top of DalvikVM

Since both the java implementation ( OpenJDK ) and Android's virtual machine DalvikVM are opensource it must be possible to implement Sun's JavaVM on top Google's DalvikVM. This would make it possible to run JVM based apps and languages ( Clojure, Jython ) out-of-the-box on the android. Is there an ongoing effort to produce such an implementation of the Sun JVM?
java android jvm

edited Jun 30 at 11:24 Nik.... 5,746 3 20 45

asked Mar 22 '09 at 13:09 George 2,519 4 31 58 86% accept rate

feedback

5 Answers
The OpenJDK makes use of native code so it would be a non-trivial port... there is at least one VM (JikesRVM) that is written in Java, unfortunately it is not a completely working implementation of Java. Since DalvikVM runs classes that were converted from .class files it should be possible to convert the classes over. Then the "only" issue is when languages generate bytecode on the fly - for that it would require the extra step of converting the generated bytecode over to the DalvikVM format while the program is running on the DalvikVM. Hmmm.... sort of a JITT (Just In Time Translator) that covertes class files to a DalvikVM files at runtime on the phone. I wonder how slow that would be.
answered Mar 22 '09 at 16:07 TofuBeer 23.6k 4 34 72 hm. like running vista in an x86 emu, inside a jvm, in 1995? :) George Mar 22 '09 at 22:32 everything old is new again :-) TofuBeer Mar 22 '09 at 23:12

feedback

Porting OpenJDK to Android platform is possible. There are effort like : Shark, Zero and caciocavallo that vastly ease the port process (= no ASM, simple AWT peer). Plus Android is nothing but a linux kernel behind. The only question is when will it be done by anybody ? By the way, both iphones and android phones got Jazelle compatible processor, somebody with very strong processor hacking skills would be very welcome to add Jazelle support to OpenJDK. Doing so, we could choose between : very light resource acceleration (Jazelle) and JIT ;-) About iPhone, it is the same thing : a port is possible. Only Apple has put a section in the the iPhone license that clearly forbid VM usage. As per European law, to me, this license section is unlegal. Two reasons : You can not force/link buy of two of your product. Here I tune and Iphones are linked. You can not refuse to sell something that you can sell. Here as soon as a VM would be build for iPhone, if it is refused to be put on the iTune store, then this point will apply. Is there anybody that want to chalenge Apple licence legality on earth ? I don't think so, unhappy people will be flying to Android or any other platform.
answered Sep 29 '09 at 10:23

1 of 2

19/10/2012 01:09 a.m.

Running Java bytecode on the Android - Sun JVM on top of DalvikVM -...

http://stackoverflow.com/questions/670987/running-java-bytecode-on-t...

testman

feedback

In the meantime I have found a possible solution (only JavaME): "MicroEmulator is a pure Java implementation of Java ME in Java SE." Running Java ME applications on Android
answered Mar 22 '09 at 16:57 George 2,519 4 31 58 feedback

technically it should be possible to interpret hotspot byte-code on dalvik vm or dalvik's byte-code on hotspot, but it will never be efficient (not mentioning elegant) design for a long run. the cost of doing that might become very high especially with respect to maintenance in the future evolution of such a split ecosystem. i think, from the very beginning, dalvik vm is a matter of power/market control rather than innovative effort to improve java virtual machine ecosystem. dalvik vm and hotspot vm are lake two highway bridges across the same river build in parallel five meters from each other. it divides and brings confusion to java technological ecosystem. google is, in my opinion, definitely the technological leader with innovative contributions over last decade that dwarf far more conservative oracle, but in this very subject they have shaken the java ecosystem in nearly destructive way. we (programmers) should strive for a single uniform solution to this problem. that is the main idea behind the concept of "virtual machine" anyway - it should not belong to neither google nor oracle.
answered Jul 24 '11 at 0:14 jan 11 1 Was this post useful to you? Yes No

I don't think the problem is technical. In theory you can migrate OpenJDK to the iPhone for example, but there are legal restriction in place.
answered Mar 22 '09 at 13:14 Peter Lawrey 117k 12 74 156 Here is the license agreement for android: developer.android.com/sdk/ . I don't see any legal barrier here. George Mar 22 '09 at 13:40 Also, the Android OS is under Apache and GPL license: source.android.com/license . So, there is no legal restriction whatsoever. George Mar 22 '09 at 15:07

feedback

Not the answer you're looking for? Browse other questions tagged java
jvm or ask your own question.

android

2 of 2

19/10/2012 01:09 a.m.

You might also like