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

Java CatchHandlerList类代码示例

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

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



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

示例1: processCatchTable

import com.android.dx.dex.code.CatchHandlerList; //导入依赖的package包/类
/**
 * Adds all exception types.
 */
private static void processCatchTable(CatchTable catchTable,
        Map<String, Set<String>> dependencies) {
    if (catchTable.size() == 0) {
        return;
    }
    for (int i = 0; i < catchTable.size(); ++i) {
        Entry entry = catchTable.get(i);
        CatchHandlerList catchHandlers = entry.getHandlers();
        for (int j = 0; j < catchHandlers.size(); ++j) {
            // TODO: Do we need these? Shouldn't they be handled by code, if
            // accessed?
            // dependencies.add(catchHandlers.get(j).getExceptionType().toHuman());
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:JDKAnalyzer.java


示例2: annotateAndConsumeHandlers

import com.android.dx.dex.code.CatchHandlerList; //导入依赖的package包/类
/**
 * Helper for {@link #annotateEntries} to annotate a catch handler list
 * while consuming it.
 *
 * @param handlers {@code non-null;} handlers to annotate
 * @param offset {@code >= 0;} the offset of this handler
 * @param size {@code >= 1;} the number of bytes the handlers consume
 * @param prefix {@code non-null;} prefix for each line
 * @param printTo {@code null-ok;} where to print to
 * @param annotateTo {@code non-null;} where to annotate to
 */
private static void annotateAndConsumeHandlers(CatchHandlerList handlers,
        int offset, int size, String prefix, PrintWriter printTo,
        AnnotatedOutput annotateTo) {
    String s = handlers.toHuman(prefix, Hex.u2(offset) + ": ");

    if (printTo != null) {
        printTo.println(s);
    }

    annotateTo.annotate(size, s);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:23,代码来源:CatchStructs.java


示例3: processCatchTable

import com.android.dx.dex.code.CatchHandlerList; //导入依赖的package包/类
/**
 * Debugging use: Builds a catch-table in XML.
 */
private void processCatchTable(CatchTable catchTable, Element codeElement) {
    if (catchTable.size() == 0) {
        return;
    }

    Element catchTableElement = new Element("catches", NS_DEX);

    for (int i = 0; i < catchTable.size(); ++i) {
        Entry entry = catchTable.get(i);
        Element entryElement = new Element("entry", NS_DEX);
        entryElement.setAttribute("start", String.valueOf(entry.getStart()));
        entryElement.setAttribute("end", String.valueOf(entry.getEnd()));

        CatchHandlerList catchHandlers = entry.getHandlers();
        for (int j = 0; j < catchHandlers.size(); ++j) {
            com.android.dx.dex.code.CatchHandlerList.Entry handlerEntry = catchHandlers.get(j);
            String exceptionType = handlerEntry.getExceptionType().toHuman();

            // We can remove the exception because a red type exception
            // will never be created or thrown.
            // This change is in sync with the one in processMethod.
            if (!isRedType(exceptionType)) {
                Element handlerElement = new Element("handler", NS_DEX);
                handlerElement.setAttribute("type", exceptionType);
                handlerElement
                        .setAttribute("target", String.valueOf(handlerEntry.getHandler()));
                entryElement.addContent(handlerElement);
            }
        }
        catchTableElement.addContent(entryElement);
    }

    codeElement.addContent(catchTableElement);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:38,代码来源:DEXmlvmOutputProcess.java


示例4: extractTargets

import com.android.dx.dex.code.CatchHandlerList; //导入依赖的package包/类
/**
 * Extracts targets that are being jumped to, so we can later add labels at
 * the corresponding positions when generating the code.
 * 
 * @return a set containing the addresses of all jump targets
 */
private static Map<Integer, Target> extractTargets(DalvInsnList instructions, CatchTable catches) {
    Map<Integer, Target> targets = new HashMap<Integer, Target>();

    // First, add non-catch targets.
    for (int i = 0; i < instructions.size(); ++i) {
        // If the target is generic, we have to assume it might jump into a
        // catch block, so we require splitting.
        if (instructions.get(i) instanceof TargetInsn) {
            TargetInsn targetInsn = (TargetInsn) instructions.get(i);
            targets.put(targetInsn.getTargetAddress(), new Target(
                    targetInsn.getTargetAddress(), true));
        } else if (instructions.get(i) instanceof SwitchData) {
            // If a switch-statement is enclosed by a try-block, we
            // will also require splitting.
            SwitchData switchData = (SwitchData) instructions.get(i);
            CodeAddress[] caseTargets = switchData.getTargets();
            for (CodeAddress caseTarget : caseTargets) {
                targets.put(caseTarget.getAddress(), new Target(caseTarget.getAddress(), true));
            }
        }
    }

    // Then, add all catch-handler targets. We need this info, so using
    // Map.put will potentially override an existing target, so the
    // information about a potential catch-handler target is not lost.
    for (int i = 0; i < catches.size(); ++i) {
        CatchHandlerList handlers = catches.get(i).getHandlers();
        for (int j = 0; j < handlers.size(); ++j) {
            int handlerAddress = handlers.get(j).getHandler();
            targets.put(handlerAddress, new Target(handlerAddress, true));
        }
    }

    return targets;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:42,代码来源:DEXmlvmOutputProcess.java


示例5: encode

import com.android.dx.dex.code.CatchHandlerList; //导入依赖的package包/类
/**
 * Encodes the handler lists.
 *
 * @param file {@code non-null;} file this instance is part of
 */
public void encode(DexFile file) {
    finishProcessingIfNecessary();

    TypeIdsSection typeIds = file.getTypeIds();
    int size = table.size();

    handlerOffsets = new TreeMap<CatchHandlerList, Integer>();

    /*
     * First add a map entry for each unique list. The tree structure
     * will ensure they are sorted when we reiterate later.
     */
    for (int i = 0; i < size; i++) {
        handlerOffsets.put(table.get(i).getHandlers(), null);
    }

    if (handlerOffsets.size() > 65535) {
        throw new UnsupportedOperationException(
                "too many catch handlers");
    }

    ByteArrayAnnotatedOutput out = new ByteArrayAnnotatedOutput();

    // Write out the handlers "header" consisting of its size in entries.
    encodedHandlerHeaderSize =
        out.writeUleb128(handlerOffsets.size());

    // Now write the lists out in order, noting the offset of each.
    for (Map.Entry<CatchHandlerList, Integer> mapping :
             handlerOffsets.entrySet()) {
        CatchHandlerList list = mapping.getKey();
        int listSize = list.size();
        boolean catchesAll = list.catchesAll();

        // Set the offset before we do any writing.
        mapping.setValue(out.getCursor());

        if (catchesAll) {
            // A size <= 0 means that the list ends with a catch-all.
            out.writeSleb128(-(listSize - 1));
            listSize--;
        } else {
            out.writeSleb128(listSize);
        }

        for (int i = 0; i < listSize; i++) {
            CatchHandlerList.Entry entry = list.get(i);
            out.writeUleb128(
                    typeIds.indexOf(entry.getExceptionType()));
            out.writeUleb128(entry.getHandler());
        }

        if (catchesAll) {
            out.writeUleb128(list.get(listSize).getHandler());
        }
    }

    encodedHandlers = out.toByteArray();
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:65,代码来源:CatchStructs.java


示例6: annotateEntries

import com.android.dx.dex.code.CatchHandlerList; //导入依赖的package包/类
/**
 * Helper method to annotate or simply print the exception handlers.
 * Only one of {@code printTo} or {@code annotateTo} should
 * be non-null.
 *
 * @param prefix {@code non-null;} prefix for each line
 * @param printTo {@code null-ok;} where to print to
 * @param annotateTo {@code null-ok;} where to consume bytes and annotate to
 */
private void annotateEntries(String prefix, PrintWriter printTo,
        AnnotatedOutput annotateTo) {
    finishProcessingIfNecessary();

    boolean consume = (annotateTo != null);
    int amt1 = consume ? 6 : 0;
    int amt2 = consume ? 2 : 0;
    int size = table.size();
    String subPrefix = prefix + "  ";

    if (consume) {
        annotateTo.annotate(0, prefix + "tries:");
    } else {
        printTo.println(prefix + "tries:");
    }

    for (int i = 0; i < size; i++) {
        CatchTable.Entry entry = table.get(i);
        CatchHandlerList handlers = entry.getHandlers();
        String s1 = subPrefix + "try " + Hex.u2or4(entry.getStart())
            + ".." + Hex.u2or4(entry.getEnd());
        String s2 = handlers.toHuman(subPrefix, "");

        if (consume) {
            annotateTo.annotate(amt1, s1);
            annotateTo.annotate(amt2, s2);
        } else {
            printTo.println(s1);
            printTo.println(s2);
        }
    }

    if (! consume) {
        // Only emit the handler lists if we are consuming bytes.
        return;
    }

    annotateTo.annotate(0, prefix + "handlers:");
    annotateTo.annotate(encodedHandlerHeaderSize,
            subPrefix + "size: " + Hex.u2(handlerOffsets.size()));

    int lastOffset = 0;
    CatchHandlerList lastList = null;

    for (Map.Entry<CatchHandlerList, Integer> mapping :
             handlerOffsets.entrySet()) {
        CatchHandlerList list = mapping.getKey();
        int offset = mapping.getValue();

        if (lastList != null) {
            annotateAndConsumeHandlers(lastList, lastOffset,
                    offset - lastOffset, subPrefix, printTo, annotateTo);
        }

        lastList = list;
        lastOffset = offset;
    }

    annotateAndConsumeHandlers(lastList, lastOffset,
            encodedHandlers.length - lastOffset,
            subPrefix, printTo, annotateTo);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:72,代码来源:CatchStructs.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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