.class 和 .dex 文件有什么区别?
当然,.dex
文件是针对Android的Dalvik VM的,而.class
文件是针对JVM的。但我想知道它们是否有类似的布局(常量池、字段、方法、属性……)?字节码不同,但是 Dalvik 特定的操作码是否与 JVM 中的操作码等效?
Of course, .dex
files are for the Dalvik VM of Android and .class
files are for the JVM. But I wonder if they have similar layouts (Constant Pool, Fields, Methods, Attributes, ...)? The bytecode is different, but are there Dalvik specific opcode equivalents to the ones from the JVM?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Dalvik可执行文件格式是VM执行的代码。 Dalvik VM无法执行Java字节码,它必须编译为dex,因为它使用备用指令集。
阅读wiki 文章。
The Dalvik Executable format is the code, the VM executes. Dalvik VM can not execute Java bytecode, it must be compiled to dex, because it uses an alternate instruction set.
Read the wiki article.
Java jar 文件有许多类文件,而每个 APK 文件只有一个
classes.dex 文件,如下所示。根据 Google 的说法,APK 格式
出于性能和安全原因,它与类文件格式不同。
Whereas a Java jar file has many class files, each APK file has only a single
classes.dex file, as shown below. According to Google, the APK format
differs from the class-file format for performance and security reasons.
有 Dex 文件格式 和 来自相应公司的类文件格式规范。
这两个文件完全不同。
There's a Dex File Format and the Class File Format specification from the respective company.
These 2 files are completely different.