Class DexUtil


  • public class DexUtil
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      DexUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int verifyCdexHeader​(byte[] buf, int offset)
      Verifies that the cdex header is valid and a supported version
      static int verifyDexHeader​(byte[] buf, int offset)
      Verifies that the dex header is valid and a supported version
      static int verifyDexHeader​(java.io.InputStream inputStream)
      Reads in the dex header from the given input stream and verifies that it is valid and a supported version The inputStream must support mark(), and will be reset to initial position upon exiting the method
      static void verifyOdexHeader​(byte[] buf, int offset)
      Verifies that the odex header is valid and a supported version
      static void verifyOdexHeader​(java.io.InputStream inputStream)
      Reads in the odex header from the given input stream and verifies that it is valid and a supported version The inputStream must support mark(), and will be reset to initial position upon exiting the method
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DexUtil

        public DexUtil()
    • Method Detail

      • verifyDexHeader

        public static int verifyDexHeader​(@Nonnull
                                          java.io.InputStream inputStream)
                                   throws java.io.IOException
        Reads in the dex header from the given input stream and verifies that it is valid and a supported version The inputStream must support mark(), and will be reset to initial position upon exiting the method
        Parameters:
        inputStream - An input stream that is positioned at a dex header
        Returns:
        The dex version
        Throws:
        DexBackedDexFile.NotADexFile - If the file is not a dex file
        DexUtil.InvalidFile - If the header appears to be a dex file, but is not valid for some reason
        DexUtil.UnsupportedFile - If the dex header is valid, but uses unsupported functionality
        java.io.IOException
      • verifyDexHeader

        public static int verifyDexHeader​(@Nonnull
                                          byte[] buf,
                                          int offset)
        Verifies that the dex header is valid and a supported version
        Parameters:
        buf - A byte array containing at least the first 44 bytes of a dex file
        offset - The offset within the array to the dex header
        Returns:
        The dex version
        Throws:
        DexBackedDexFile.NotADexFile - If the file is not a dex file
        DexUtil.InvalidFile - If the header appears to be a dex file, but is not valid for some reason
        DexUtil.UnsupportedFile - If the dex header is valid, but uses unsupported functionality
      • verifyCdexHeader

        public static int verifyCdexHeader​(@Nonnull
                                           byte[] buf,
                                           int offset)
        Verifies that the cdex header is valid and a supported version
        Parameters:
        buf - A byte array containing at least the first 44 bytes of a cdex file
        offset - The offset within the array to the dex header
        Returns:
        The dex version
        Throws:
        DexBackedDexFile.NotADexFile - If the file is not a cdex file
        DexUtil.InvalidFile - If the header appears to be a cdex file, but is not valid for some reason
        DexUtil.UnsupportedFile - If the cdex header is valid, but uses unsupported functionality
      • verifyOdexHeader

        public static void verifyOdexHeader​(@Nonnull
                                            java.io.InputStream inputStream)
                                     throws java.io.IOException
        Reads in the odex header from the given input stream and verifies that it is valid and a supported version The inputStream must support mark(), and will be reset to initial position upon exiting the method
        Parameters:
        inputStream - An input stream that is positioned at an odex header
        Throws:
        DexBackedOdexFile.NotAnOdexFile - If the file is not an odex file
        DexUtil.UnsupportedFile - If the odex header is valid, but is an unsupported version
        java.io.IOException
      • verifyOdexHeader

        public static void verifyOdexHeader​(@Nonnull
                                            byte[] buf,
                                            int offset)
        Verifies that the odex header is valid and a supported version
        Parameters:
        buf - A byte array containing at least the first 8 bytes of an odex file
        offset - The offset within the array to the odex header
        Throws:
        DexBackedOdexFile.NotAnOdexFile - If the file is not an odex file
        DexUtil.UnsupportedFile - If the odex header is valid, but uses unsupported functionality