• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DexFormat类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.android.dex.DexFormat的典型用法代码示例。如果您正苦于以下问题:Java DexFormat类的具体用法?Java DexFormat怎么用?Java DexFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DexFormat类属于com.android.dex包,在下文中一共展示了DexFormat类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: writeHeaderPart

import com.android.dex.DexFormat; //导入依赖的package包/类
/**
 * Writes the portion of the file header that refers to this instance.
 *
 * @param out {@code non-null;} where to write
 */
public void writeHeaderPart(AnnotatedOutput out) {
    throwIfNotPrepared();

    int sz = typeIds.size();
    int offset = (sz == 0) ? 0 : getFileOffset();

    if (sz > DexFormat.MAX_TYPE_IDX + 1) {
        throw new DexIndexOverflowException("Too many type references: " + sz +
                "; max is " + (DexFormat.MAX_TYPE_IDX + 1) + ".\n" +
                Main.getTooManyIdsErrorMessage());
    }

    if (out.annotates()) {
        out.annotate(4, "type_ids_size:   " + Hex.u4(sz));
        out.annotate(4, "type_ids_off:    " + Hex.u4(offset));
    }

    out.writeInt(sz);
    out.writeInt(offset);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:26,代码来源:TypeIdsSection.java


示例2: getTooManyMembersMessage

import com.android.dex.DexFormat; //导入依赖的package包/类
private String getTooManyMembersMessage() {
    Map<String, AtomicInteger> membersByPackage = new TreeMap<String, AtomicInteger>();
    for (Object member : items()) {
        String packageName = ((MemberIdItem) member).getDefiningClass().getPackageName();
        AtomicInteger count = membersByPackage.get(packageName);
        if (count == null) {
            count = new AtomicInteger();
            membersByPackage.put(packageName, count);
        }
        count.incrementAndGet();
    }

    Formatter formatter = new Formatter();
    try {
        String memberType = this instanceof MethodIdsSection ? "method" : "field";
        formatter.format("Too many %s references: %d; max is %d.%n%n" +
                "References by package:",
                memberType, items().size(), DexFormat.MAX_MEMBER_IDX + 1);
        for (Map.Entry<String, AtomicInteger> entry : membersByPackage.entrySet()) {
            formatter.format("%n%6d %s", entry.getValue().get(), entry.getKey());
        }
        return formatter.toString();
    } finally {
        formatter.close();
    }
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:27,代码来源:MemberIdsSection.java


示例3: writeHeaderPart

import com.android.dex.DexFormat; //导入依赖的package包/类
/**
 * Writes the portion of the file header that refers to this instance.
 *
 * @param out {@code non-null;} where to write
 */
public void writeHeaderPart(AnnotatedOutput out) {
    throwIfNotPrepared();

    int sz = typeIds.size();
    int offset = (sz == 0) ? 0 : getFileOffset();

    if (sz > DexFormat.MAX_TYPE_IDX + 1) {
        throw new DexException("Too many type references: " + sz +
                "; max is " + (DexFormat.MAX_TYPE_IDX + 1) + ".\n");
    }

    if (out.annotates()) {
        out.annotate(4, "type_ids_size:   " + Hex.u4(sz));
        out.annotate(4, "type_ids_off:    " + Hex.u4(offset));
    }

    out.writeInt(sz);
    out.writeInt(offset);
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:25,代码来源:TypeIdsSection.java


示例4: orderItems

import com.android.dex.DexFormat; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void orderItems() {
    int idx = 0;

    if (items().size() > DexFormat.MAX_MEMBER_IDX + 1) {
        throw new DexIndexOverflowException(getTooManyMembersMessage());
    }

    for (Object i : items()) {
        ((MemberIdItem) i).setIndex(idx);
        idx++;
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:15,代码来源:MemberIdsSection.java


示例5: getTooManyMembersMessage

import com.android.dex.DexFormat; //导入依赖的package包/类
private String getTooManyMembersMessage() {
    Map<String, AtomicInteger> membersByPackage = new TreeMap<String, AtomicInteger>();
    for (Object member : items()) {
        String packageName = ((MemberIdItem) member).getDefiningClass().getPackageName();
        AtomicInteger count = membersByPackage.get(packageName);
        if (count == null) {
            count = new AtomicInteger();
            membersByPackage.put(packageName, count);
        }
        count.incrementAndGet();
    }

    Formatter formatter = new Formatter();
    try {
        String memberType = this instanceof MethodIdsSection ? "method" : "field";
        formatter.format("Too many %s references: %d; max is %d.%n" +
                Main.getTooManyIdsErrorMessage() + "%n" +
                "References by package:",
                memberType, items().size(), DexFormat.MAX_MEMBER_IDX + 1);
        for (Map.Entry<String, AtomicInteger> entry : membersByPackage.entrySet()) {
            formatter.format("%n%6d %s", entry.getValue().get(), entry.getKey());
        }
        return formatter.toString();
    } finally {
        formatter.close();
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:28,代码来源:MemberIdsSection.java


示例6: getDexFileName

import com.android.dex.DexFormat; //导入依赖的package包/类
private static String getDexFileName(int i) {
    if (i == 0) {
        return DexFormat.DEX_IN_JAR_NAME;
    } else {
        return DEX_PREFIX + (i + 1) + DEX_EXTENSION;
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:8,代码来源:Main.java


示例7: makeManifest

import com.android.dex.DexFormat; //导入依赖的package包/类
/**
 * Creates and returns the manifest to use for the output. This may
 * modify {@link #outputResources} (removing the pre-existing manifest).
 *
 * @return {@code non-null;} the manifest
 */
private static Manifest makeManifest() throws IOException {
    byte[] manifestBytes = outputResources.get(MANIFEST_NAME);
    Manifest manifest;
    Attributes attribs;

    if (manifestBytes == null) {
        // We need to construct an entirely new manifest.
        manifest = new Manifest();
        attribs = manifest.getMainAttributes();
        attribs.put(Attributes.Name.MANIFEST_VERSION, "1.0");
    } else {
        manifest = new Manifest(new ByteArrayInputStream(manifestBytes));
        attribs = manifest.getMainAttributes();
        outputResources.remove(MANIFEST_NAME);
    }

    String createdBy = attribs.getValue(CREATED_BY);
    if (createdBy == null) {
        createdBy = "";
    } else {
        createdBy += " + ";
    }
    createdBy += "dx " + Version.VERSION;

    attribs.put(CREATED_BY, createdBy);
    attribs.putValue("Dex-Location", DexFormat.DEX_IN_JAR_NAME);

    return manifest;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:36,代码来源:Main.java


示例8: orderItems

import com.android.dex.DexFormat; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void orderItems() {
    int idx = 0;

    if (items().size() > DexFormat.MAX_MEMBER_IDX + 1) {
        throw new DexException(getTooManyMembersMessage());
    }

    for (Object i : items()) {
        ((MemberIdItem) i).setIndex(idx);
        idx++;
    }
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:15,代码来源:MemberIdsSection.java


示例9: makeManifest

import com.android.dex.DexFormat; //导入依赖的package包/类
/**
 * Creates and returns the manifest to use for the output. This may
 * modify {@link #outputResources} (removing the pre-existing manifest).
 *
 * @return {@code non-null;} the manifest
 */
private Manifest makeManifest() throws IOException {
    byte[] manifestBytes = outputResources.get(MANIFEST_NAME);
    Manifest manifest;
    Attributes attribs;

    if (manifestBytes == null) {
        // We need to construct an entirely new manifest.
        manifest = new Manifest();
        attribs = manifest.getMainAttributes();
        attribs.put(Attributes.Name.MANIFEST_VERSION, "1.0");
    } else {
        manifest = new Manifest(new ByteArrayInputStream(manifestBytes));
        attribs = manifest.getMainAttributes();
        outputResources.remove(MANIFEST_NAME);
    }

    String createdBy = attribs.getValue(CREATED_BY);
    if (createdBy == null) {
        createdBy = "";
    } else {
        createdBy += " + ";
    }
    createdBy += "dx " + Version.VERSION;

    attribs.put(CREATED_BY, createdBy);
    attribs.putValue("Dex-Location", DexFormat.DEX_IN_JAR_NAME);

    return manifest;
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:36,代码来源:Main.java


示例10: writeTo

import com.android.dex.DexFormat; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void writeTo(DexFile file, AnnotatedOutput out) {
    int mapOff = file.getMap().getFileOffset();
    Section firstDataSection = file.getFirstDataSection();
    Section lastDataSection = file.getLastDataSection();
    int dataOff = firstDataSection.getFileOffset();
    int dataSize = lastDataSection.getFileOffset() +
        lastDataSection.writeSize() - dataOff;

    String magic = file.getDexOptions().getMagic();

    if (out.annotates()) {
        out.annotate(8, "magic: " + new CstString(magic).toQuoted());
        out.annotate(4, "checksum");
        out.annotate(20, "signature");
        out.annotate(4, "file_size:       " +
                     Hex.u4(file.getFileSize()));
        out.annotate(4, "header_size:     " + Hex.u4(SizeOf.HEADER_ITEM));
        out.annotate(4, "endian_tag:      " + Hex.u4(DexFormat.ENDIAN_TAG));
        out.annotate(4, "link_size:       0");
        out.annotate(4, "link_off:        0");
        out.annotate(4, "map_off:         " + Hex.u4(mapOff));
    }

    // Write the magic number.
    for (int i = 0; i < 8; i++) {
        out.writeByte(magic.charAt(i));
    }

    // Leave space for the checksum and signature.
    out.writeZeroes(24);

    out.writeInt(file.getFileSize());
    out.writeInt(SizeOf.HEADER_ITEM);
    out.writeInt(DexFormat.ENDIAN_TAG);

    /*
     * Write zeroes for the link size and data, as the output
     * isn't a staticly linked file.
     */
    out.writeZeroes(8);

    out.writeInt(mapOff);

    // Write out each section's respective header part.
    file.getStringIds().writeHeaderPart(out);
    file.getTypeIds().writeHeaderPart(out);
    file.getProtoIds().writeHeaderPart(out);
    file.getFieldIds().writeHeaderPart(out);
    file.getMethodIds().writeHeaderPart(out);
    file.getClassDefs().writeHeaderPart(out);

    if (out.annotates()) {
        out.annotate(4, "data_size:       " + Hex.u4(dataSize));
        out.annotate(4, "data_off:        " + Hex.u4(dataOff));
    }

    out.writeInt(dataSize);
    out.writeInt(dataOff);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:62,代码来源:HeaderItem.java


示例11: getMagic

import com.android.dex.DexFormat; //导入依赖的package包/类
/**
 * Gets the dex file magic number corresponding to this instance.
 */
public String getMagic() {
    return DexFormat.apiToMagic(targetApiLevel);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:7,代码来源:DexOptions.java


示例12: runMonoDex

import com.android.dex.DexFormat; //导入依赖的package包/类
private static int runMonoDex() throws IOException {

        File incrementalOutFile = null;
        if (args.incremental) {
            if (args.outName == null) {
                System.err.println(
                        "error: no incremental output name specified");
                return -1;
            }
            incrementalOutFile = new File(args.outName);
            if (incrementalOutFile.exists()) {
                minimumFileAge = incrementalOutFile.lastModified();
            }
        }

        if (!processAllFiles()) {
            return 1;
        }

        if (args.incremental && !anyFilesProcessed) {
            return 0; // this was a no-op incremental build
        }

        // this array is null if no classes were defined
        byte[] outArray = null;

        if (!outputDex.isEmpty() || (args.humanOutName != null)) {
            outArray = writeDex();

            if (outArray == null) {
                return 2;
            }
        }

        if (args.incremental) {
            outArray = mergeIncremental(outArray, incrementalOutFile);
        }

        outArray = mergeLibraryDexBuffers(outArray);

        if (args.jarOutput) {
            // Effectively free up the (often massive) DexFile memory.
            outputDex = null;

            if (outArray != null) {
                outputResources.put(DexFormat.DEX_IN_JAR_NAME, outArray);
            }
            if (!createJar(args.outName)) {
                return 3;
            }
        } else if (outArray != null && args.outName != null) {
            OutputStream out = openOutput(args.outName);
            out.write(outArray);
            closeOutput(out);
        }

        return 0;
    }
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:59,代码来源:Main.java


示例13: processFileBytes

import com.android.dex.DexFormat; //导入依赖的package包/类
/**
 * Processes one file, which may be either a class or a resource.
 *
 * @param name {@code non-null;} name of the file
 * @param bytes {@code non-null;} contents of the file
 * @return whether processing was successful
 */
private static boolean processFileBytes(String name, long lastModified, byte[] bytes) {
    boolean isClass = name.endsWith(".class");
    boolean isClassesDex = name.equals(DexFormat.DEX_IN_JAR_NAME);
    boolean keepResources = (outputResources != null);

    if (!isClass && !isClassesDex && !keepResources) {
        if (args.verbose) {
            DxConsole.out.println("ignored resource " + name);
        }
        return false;
    }

    if (args.verbose) {
        DxConsole.out.println("processing " + name + "...");
    }

    String fixedName = fixPath(name);

    if (isClass) {

        if (keepResources && args.keepClassesInJar) {
            synchronized (outputResources) {
                outputResources.put(fixedName, bytes);
            }
        }
        if (lastModified < minimumFileAge) {
            return true;
        }
        return processClass(fixedName, bytes);
    } else if (isClassesDex) {
        synchronized (libraryDexBuffers) {
            libraryDexBuffers.add(bytes);
        }
        return true;
    } else {
        synchronized (outputResources) {
            outputResources.put(fixedName, bytes);
        }
        return true;
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:49,代码来源:Main.java


示例14: processFileBytes

import com.android.dex.DexFormat; //导入依赖的package包/类
/**
 * Processes one file, which may be either a class or a resource.
 *
 * @param name {@code non-null;} name of the file
 * @param bytes {@code non-null;} contents of the file
 * @return whether processing was successful
 */
private static boolean processFileBytes(String name, long lastModified, byte[] bytes) {

    boolean isClass = name.endsWith(".class");
    boolean isClassesDex = name.equals(DexFormat.DEX_IN_JAR_NAME);
    boolean keepResources = (outputResources != null);

    if (!isClass && !isClassesDex && !keepResources) {
        throw new RuntimeException("ignored resource " + name);
    }

    if (args.verbose) {
        System.out.println("processing " + name + "...");
    }

    String fixedName = fixPath(name);

    if (isClass) {

        if (keepResources && args.keepClassesInJar) {
            synchronized (outputResources) {
                outputResources.put(fixedName, bytes);
            }
        }
        if (lastModified < minimumFileAge) {
            return true;
        }
        processClass(fixedName, bytes);
        // Assume that an exception may occur. Status will be updated
        // asynchronously, if the class compiles without error.
        return false;
    } else if (isClassesDex) {
        synchronized (libraryDexBuffers) {
            libraryDexBuffers.add(bytes);
        }
        return true;
    } else {
        synchronized (outputResources) {
            outputResources.put(fixedName, bytes);
        }
        return true;
    }
}
 
开发者ID:RunasSudo,项目名称:PyAndroid,代码行数:50,代码来源:Dexer.java


示例15: runMonoDex

import com.android.dex.DexFormat; //导入依赖的package包/类
private static int runMonoDex() throws IOException {

        File incrementalOutFile = null;
        if (args.incremental) {
            if (args.outName == null) {
                System.err.println(
                        "error: no incremental output name specified");
                return -1;
            }
            incrementalOutFile = new File(args.outName);
            if (incrementalOutFile.exists()) {
                minimumFileAge = incrementalOutFile.lastModified();
            }
        }

        if (!processAllFiles()) {
            return 1;
        }

        if (args.incremental && !anyFilesProcessed) {
            return 0; // this was a no-op incremental build
        }

        // this array is null if no classes were defined
        byte[] outArray = null;

        if (!outputDex.isEmpty() || (args.humanOutName != null)) {
            outArray = writeDex(outputDex);

            if (outArray == null) {
                return 2;
            }
        }

        if (args.incremental) {
            outArray = mergeIncremental(outArray, incrementalOutFile);
        }

        outArray = mergeLibraryDexBuffers(outArray);

        if (args.jarOutput) {
            // Effectively free up the (often massive) DexFile memory.
            outputDex = null;

            if (outArray != null) {
                outputResources.put(DexFormat.DEX_IN_JAR_NAME, outArray);
            }
            if (!createJar(args.outName)) {
                return 3;
            }
        } else if (outArray != null && args.outName != null) {
            OutputStream out = openOutput(args.outName);
            out.write(outArray);
            closeOutput(out);
        }

        return 0;
    }
 
开发者ID:johnlee175,项目名称:dex,代码行数:59,代码来源:Main.java


示例16: processFileBytes

import com.android.dex.DexFormat; //导入依赖的package包/类
/**
 * Processes one file, which may be either a class or a resource.
 *
 * @param name {@code non-null;} name of the file
 * @param bytes {@code non-null;} contents of the file
 * @return whether processing was successful
 */
private static boolean processFileBytes(String name, long lastModified, byte[] bytes) {

    boolean isClass = name.endsWith(".class");
    boolean isClassesDex = name.equals(DexFormat.DEX_IN_JAR_NAME);
    boolean keepResources = (outputResources != null);

    if (!isClass && !isClassesDex && !keepResources) {
        if (args.verbose) {
            DxConsole.out.println("ignored resource " + name);
        }
        return false;
    }

    if (args.verbose) {
        DxConsole.out.println("processing " + name + "...");
    }

    String fixedName = fixPath(name);

    if (isClass) {

        if (keepResources && args.keepClassesInJar) {
            synchronized (outputResources) {
                outputResources.put(fixedName, bytes);
            }
        }
        if (lastModified < minimumFileAge) {
            return true;
        }
        processClass(fixedName, bytes);
        // Assume that an exception may occur. Status will be updated
        // asynchronously, if the class compiles without error.
        return false;
    } else if (isClassesDex) {
        synchronized (libraryDexBuffers) {
            libraryDexBuffers.add(bytes);
        }
        return true;
    } else {
        synchronized (outputResources) {
            outputResources.put(fixedName, bytes);
        }
        return true;
    }
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:53,代码来源:Main.java



注:本文中的com.android.dex.DexFormat类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JProductFinder类代码示例发布时间:2022-05-23
下一篇:
Java InlineTree类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap