【问题标题】:Why is there unsigned type in DEX executables when there's no unsigned type in Java?当 Java 中没有无符号类型时,为什么 DEX 可执行文件中有无符号类型?
【发布时间】:2015-05-28 01:18:43
【问题描述】:

DEX 格式的无符号类型有:

ubyte       8-bit unsigned int
ushort      16-bit unsigned int, little-endian
uint        32-bit unsigned int, little-endian
ulong       64-bit unsigned int, little-endian
uleb128     unsigned LEB128, variable-length (see below)
uleb128p1   unsigned LEB128 plus 1, variable-length (see below)

https://source.android.com/devices/tech/dalvik/dex-format.html

然而,无符号类型是从 Java 8 开始引入的,Android 的 dx 以及 Jack 和 Jill 编译器仍然不支持 Java 8。那么为什么要引入这些类型呢? Java 代码是否有机会发出使用这些类型的指令?

【问题讨论】:

    标签: android types dalvik unsigned


    【解决方案1】:

    这些类型用于 DEX 文件格式本身。标头中的元数据(包含方法计数和文件偏移量等内容)与任何特定语言无关。

    此外,DEX 还可用于非 Java 语言。

    【讨论】:

    • Java 字节码也可用于非 Java 语言。 Java 类文件可能还需要像这样存储方法计数和文件偏移量,但它们不需要无符号类型
    • 您阅读过 Java 字节码参考吗?它使用许多无符号值。例如,docs.oracle.com/javase/specs/jvms/se7/html/… 使用无符号字节索引或“宽”版本的无符号两字节索引。
    猜你喜欢
    • 2011-04-05
    • 1970-01-01
    • 1970-01-01
    • 2014-02-01
    • 2017-05-15
    • 2019-06-10
    • 2017-04-05
    • 2012-01-23
    相关资源
    最近更新 更多