你能不能在Dalvik虚拟机(Android的虚拟机),这样做就可以在阳光VM? [英] What can you not do on the Dalvik VM (Android's VM) that you can in Sun VM?

查看:125
本文介绍了你能不能在Dalvik虚拟机(Android的虚拟机),这样做就可以在阳光VM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,你可以的Dalvik的虚拟机上运行几乎所有的Java就可以在Java的虚拟机,但限制也不是很清楚。有没有人遇到任何重大的绊脚石?遇到问题的任何主要图书馆?编译成Java字节code任何语言(斯卡拉,Jython的等等)无法正常工作?

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?

推荐答案

有一些东西的Dalvik不会处理或不处理以同样的方式为标准的Java字节code,但大部分都是相当先进的。

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.

最严重的例子是运行时字节code一代和自定义类加载。比方说,你想创造一些字节code,然后使用类加载器来加载它给你,如果这招适用于你的正常的机器,它保证在Dalvik的不行,除非你改变你的字节code产生。

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.

这prevents您使用某些依赖注入框架,其中最著名的例子是谷歌吉斯(虽然我相信有些人工作的)。在另一方面的AspectJ应该工作,因为它使用字节code仪器仪表作为编译步骤(虽然我不知道是否有人尝试过​​)。

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).

至于其他JVM语言 - 任何最终编译成字节的标准code和不使用运行时字节code仪表可以转换为Dalvik的,应该工作。我知道人们都在Android上运行Jython和它的工作确定。

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.

其他的事情需要注意的是,有不只是在时间编译的。这不是严格Dalviks问题(你总是可以在飞行中,如果你想编译任何字节code),但Android不支持,也不可能这样做。在效果,而microbenchmarking标准Java是没有用的 - 组件的测试有不同的运行characterstics不是作为更大系统的部分 - 微基准为Android手机完全意义

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.

这篇关于你能不能在Dalvik虚拟机(Android的虚拟机),这样做就可以在阳光VM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆