简体   繁体   English

JVM与Dalvik和/或ART有何不同?

[英]How exactly does JVM differ from Dalvik and/or ART?

Firstly, I think I may have titled this question poorly, but I couldn't think of the right words, so please, feel free to suggest an edit and I will make it, so that the question is more educational and relevant to others. 首先,我想我可能会把这个问题标题很差,但是我想不出正确的话,所以请随意提出一个编辑,然后我会做出来,这样问题就更有教育意义并且与其他人相关。

I know that javax.Swing simply cannot be used for an Android project, and I've accepted this and learned Android XML based UI design, but just out of curiosity, I want to know exactly why . 我知道javax.Swing根本不能用于Android项目,我已经接受了这个并学习了基于Android XML的UI设计,但出于好奇,我想确切地知道原因

I realize that the screen dimensions of a phone might be something Swing wouldn't handle well, but what is to stop a developer from simply importing the javax.Swing package (besides Android Studio simply not letting it happen in the first place), however deformed and hideous Swing windows might be on an Android device screen? 我意识到手机的屏幕尺寸可能是Swing不能很好地处理的东西,但是什么是阻止开发人员简单地导入javax.Swing包(除了Android Studio之外根本不让它发生)变形和丑陋的摇摆窗口可能在Android设备屏幕上? I also realize that AWT and SWT would also have to be imported, but the same question applies to these packages as well. 我也意识到AWT和SWT也必须被导入,但同样的问题也适用于这些包。

I think my lack of understanding of this might really root from a lack of understanding of how the Java Virtual Machine and the Android equivalent (is Dalvik still used, or have they switched cold-turkey to ART?). 我认为我对此缺乏了解可能真的源于缺乏对Java虚拟机和Android等价物的理解(Dalvik仍在使用,还是他们将冷火鸡转换为ART?)。

As always, any information or reading on the subject you can provide is greatly appreciated. 与往常一样,非常感谢您提供的任何信息或阅读主题。 I really want to learn more about the fundamentals of how the JVM, Dalvik, and ART work. 我真的想要了解更多关于JVM,Dalvik和ART如何工作的基础知识。

There are at least three fundamental differences: 至少有三个根本区别:

  • the APIs differ; API不同; for instance, even the most recent versions of Android's SDK don't have JSR 203; 例如,即使最新版本的Android SDK也没有JSR 203;
  • the binary formats differ; 二进制格式不同; Dalvik/ART does not generate JVM bytecode; Dalvik / ART不生成JVM字节码;
  • the language level differs; 语言水平不同; it is partly a consequence of the previous point, since in order to support a given language level, Dalvik/ART has to reimplement all the parsing/bytecode production to fit its own VM. 这部分是前一点的结果,因为为了支持给定的语言级别,Dalvik / ART必须重新实现所有解析/字节码生成以适应其自己的VM。

The latter point means that as a result, there is still no mainstream support in Android of try-with-resources which appeared in Java 5 years ago; 的最后一点意味着,作为一个结果,还有Android中没有主流支持并重,以资源出现于Java的5 年前 ; various efforts have seen the day to support this plus Java 8's "goodies" over time, but none of them is really Java "at the core"; 随着时间的推移,各种各样的努力已经看到了支持这个以及Java 8的“好东西”,但它们都不是真正的Java“核心”; understand, they do not use the JVM, they do not use the Java compiler. 明白,他们不使用JVM,他们不使用Java编译器。

Recent news tells that this is bound to change in "Android N" (which will actually use OpenJDK). 最近的消息告诉我,这肯定会改变“Android N”(实际上会使用OpenJDK)。 Which is good news. 这是个好消息。 Also, as to point 1, you may recall that infamous Oracle vs Google case with regards to APIs being copyrightable... This is still not completely settled. 此外,关于第1点,您可能还记得臭名昭着的Oracle与谷歌案件有关API的版权......这仍然没有完全解决。

This article might be helpful to you http://www.techentice.com/dalvik-vs-art-android-drop-dalvik-efficient-art/ although, it is somewhat outdated, ALREADY. 本文可能对您有所帮助http://www.techentice.com/dalvik-vs-art-android-drop-dalvik-efficient-art/尽管它有点过时,已经过时了。 It does, however explain differences between JVM and DALVIK and ART. 然而,它解释了JVM与DALVIK和ART之间的差异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM