当前位置: 首页>>代码示例>>Java>>正文


Java HeaderItem.getVersion方法代码示例

本文整理汇总了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));
    }
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:33,代码来源:DexUtil.java

示例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);
}
 
开发者ID:DexPatcher,项目名称:multidexlib2,代码行数:9,代码来源:RawDexIO.java

示例3: getHighestDexVersionFromApiLevel

import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入方法依赖的package包/类
public static int getHighestDexVersionFromApiLevel(int apiLevel) {
	return HeaderItem.getVersion(HeaderItem.getMagicForApi(apiLevel), 0);
}
 
开发者ID:DexPatcher,项目名称:multidexlib2,代码行数:4,代码来源:DexVersionMap.java


注:本文中的org.jf.dexlib2.dexbacked.raw.HeaderItem.getVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。