本文整理汇总了Java中org.jf.dexlib2.dexbacked.raw.HeaderItem.getVersion方法的典型用法代码示例。如果您正苦于以下问题:Java HeaderItem.getVersion方法的具体用法?Java HeaderItem.getVersion怎么用?Java HeaderItem.getVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jf.dexlib2.dexbacked.raw.HeaderItem
的用法示例。
在下文中一共展示了HeaderItem.getVersion方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyDexHeader
import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入方法依赖的package包/类
/**
* Verifies that the dex header is valid and a supported version
*
* @param buf A byte array containing at least the first 44 bytes of a dex file
* @param offset The offset within the array to the dex header
* @throws NotADexFile If the file is not a dex file
* @throws InvalidFile If the header appears to be a dex file, but is not valid for some reason
* @throws UnsupportedFile If the dex header is valid, but uses unsupported functionality
*/
public static void verifyDexHeader( byte[] buf, int offset) {
int dexVersion = HeaderItem.getVersion(buf, offset);
if (dexVersion == -1) {
StringBuilder sb = new StringBuilder("Not a valid dex magic value:");
for (int i=0; i<8; i++) {
sb.append(String.format(" %02x", buf[i]));
}
throw new NotADexFile(sb.toString());
}
if (!HeaderItem.isSupportedDexVersion(dexVersion)) {
throw new UnsupportedFile(String.format("Dex version %03d is not supported", dexVersion));
}
int endian = HeaderItem.getEndian(buf, offset);
if (endian == HeaderItem.BIG_ENDIAN_TAG) {
throw new UnsupportedFile("Big endian dex files are not supported");
}
if (endian != HeaderItem.LITTLE_ENDIAN_TAG) {
throw new InvalidFile(String.format("Invalid endian tag: 0x%x", endian));
}
}
示例2: readRawDexFile
import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入方法依赖的package包/类
public static DexBackedDexFile readRawDexFile(byte[] buf, int offset, Opcodes opcodes) throws IOException {
DexUtil.verifyDexHeader(buf, offset);
if (opcodes == null) {
int dexVersion = HeaderItem.getVersion(buf, offset);
opcodes = OpcodeUtils.getOpcodesFromDexVersion(dexVersion);
};
return new DexBackedDexFile(opcodes, buf, 0);
}
示例3: getHighestDexVersionFromApiLevel
import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入方法依赖的package包/类
public static int getHighestDexVersionFromApiLevel(int apiLevel) {
return HeaderItem.getVersion(HeaderItem.getMagicForApi(apiLevel), 0);
}