views:

2968

answers:

2

I know that you can run almost all Java in Dalvik's VM that you can in Java's VM but the limitations are not very clear. Has anyone run into any major stumbling blocks? Any major libraries having trouble? Any languages that compile to Java bytecode (Scala, Jython etc...) not work as expected?

+9  A: 

There is a number of things that Dalvik will not handle or will not handle quite the same way as standard Java bytecode, though most of them are quite advanced.

The most severe example is runtime bytecode generation and custom class loading. Let's say you would like to create some bytecode and then use classloader to load it for you, if that trick works on your normal machine, it is guaranteed to not work on Dalvik, unless you change your bytecode generation.

That prevents you from using certain dependency injection frameworks, most known example being Google Guice (though I am sure some people work on that). On the other hand AspectJ should work as it uses bytecode instrumentation as a compilation step (though I dunno if anyone tried).

As to other jvm languages -- anything that in the end compiles to standard bytecode and does not use bytecode instrumentation at runtime can be converted to Dalvik and should work. I know people did run Jython on Android and it worked ok.

Other thing to be aware of is that there is no just in time compilation. This is not strictly Dalviks problem (you can always compile any bytecode on the fly if you wish) but that Android does not support that and is unlikely to do so. In the effect while microbenchmarking for standard Java was useless -- components had different runtime characterstics in tests than as parts of larger systems -- microbenchmarks for Android phones totally make sense.

Marcin
A few updates:There's a special build of Guice that'll work on Android.http://code.google.com/p/google-guice/downloads/detail?name=guice-2.0-no_aop.jarGoogle has a team working on a JIT for Android.http://groups.google.com/group/android-platform/browse_thread/thread/331d5f5636f5f532
Jesse Wilson
From Android Froyo it support trace-granularity JIT compiler.
Wonil
+2  A: 

If you see "Dalvik Virtual Machine internals" Google IO session, you can find Dalvik does not support generational GC.

So, it could degrade performance of frequent object creation and deletion. Java VM supports generational GC so, it would show better GC performance for the same situation.

Wonil