Class DexFormat

java.lang.Object
com.android.dex.DexFormat

public final class DexFormat extends Object
Constants that show up in and are otherwise related to .dex files, and helper methods for same.
  • Field Details

    • API_SPACES_IN_SIMPLE_NAME

      public static final int API_SPACES_IN_SIMPLE_NAME
      API level to target in order to allow spaces in SimpleName
      See Also:
    • API_CONST_METHOD_HANDLE

      public static final int API_CONST_METHOD_HANDLE
      API level to target in order to generate const-method-handle and const-method-type
      See Also:
    • API_METHOD_HANDLES

      public static final int API_METHOD_HANDLES
      API level to target in order to generate invoke-polymorphic and invoke-custom
      See Also:
    • API_DEFINE_INTERFACE_METHODS

      public static final int API_DEFINE_INTERFACE_METHODS
      API level to target in order to define default and static interface methods
      See Also:
    • API_INVOKE_INTERFACE_METHODS

      public static final int API_INVOKE_INTERFACE_METHODS
      API level to target in order to invoke default and static interface methods
      See Also:
    • API_INVOKE_STATIC_INTERFACE_METHODS

      public static final int API_INVOKE_STATIC_INTERFACE_METHODS
      API level at which the invocation of static interface methods is permitted by dx. This value has been determined experimentally by testing on different VM versions.
      See Also:
    • API_NO_EXTENDED_OPCODES

      public static final int API_NO_EXTENDED_OPCODES
      API level to target in order to suppress extended opcode usage
      See Also:
    • API_CURRENT

      public static final int API_CURRENT
      API level to target in order to produce the most modern file format
      See Also:
    • VERSION_FOR_API_10000

      public static final String VERSION_FOR_API_10000
      dex file version number for API level 10000 and earlier
      See Also:
    • VERSION_FOR_API_28

      public static final String VERSION_FOR_API_28
      dex file version number for API level 28 and earlier
      See Also:
    • VERSION_FOR_API_26

      public static final String VERSION_FOR_API_26
      dex file version number for API level 26 and earlier
      See Also:
    • VERSION_FOR_API_24

      public static final String VERSION_FOR_API_24
      dex file version number for API level 24 and earlier
      See Also:
    • VERSION_FOR_API_13

      public static final String VERSION_FOR_API_13
      dex file version number for API level 13 and earlier
      See Also:
    • VERSION_CURRENT

      public static final String VERSION_CURRENT
      Dex file version number for dalvik.

      Note: Dex version 36 was loadable in some versions of Dalvik but was never fully supported or completed and is not considered a valid dex file format.

      See Also:
    • DEX_IN_JAR_NAME

      public static final String DEX_IN_JAR_NAME
      file name of the primary .dex file inside an application or library .jar file
      See Also:
    • MAGIC_PREFIX

      public static final String MAGIC_PREFIX
      common prefix for all dex file "magic numbers"
      See Also:
    • MAGIC_SUFFIX

      public static final String MAGIC_SUFFIX
      common suffix for all dex file "magic numbers"
      See Also:
    • ENDIAN_TAG

      public static final int ENDIAN_TAG
      value used to indicate endianness of file contents
      See Also:
    • MAX_MEMBER_IDX

      public static final int MAX_MEMBER_IDX
      Maximum addressable field or method index. The largest addressable member is 0xffff, in the "instruction formats" spec as field@CCCC or meth@CCCC.
      See Also:
    • MAX_TYPE_IDX

      public static final int MAX_TYPE_IDX
      Maximum addressable type index. The largest addressable type is 0xffff, in the "instruction formats" spec as type@CCCC.
      See Also:
  • Method Details

    • magicToApi

      public static int magicToApi(byte[] magic)
      Returns the API level corresponding to the given magic number, or -1 if the given array is not a well-formed dex file magic number.
      Parameters:
      magic - array of bytes containing DEX file magic string
      Returns:
      API level corresponding to magic string if valid, -1 otherwise.
    • apiToMagic

      public static String apiToMagic(int targetApiLevel)
      Returns the magic number corresponding to the given target API level.
      Parameters:
      targetApiLevel - level of API (minimum supported value 13).
      Returns:
      Magic string corresponding to API level supplied.
    • isSupportedDexMagic

      public static boolean isSupportedDexMagic(byte[] magic)
      Checks whether a DEX file magic string is supported.
      Parameters:
      magic - string from DEX file
      Returns: