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

Java Method类代码示例

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

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



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

示例1: endParsingMember

import com.android.dx.cf.iface.Method; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void endParsingMember(ByteArray bytes, int offset, String name,
        String descriptor, Member member) {
    if (!(member instanceof Method)) {
        return;
    }

    if (!shouldDumpMethod(name)) {
        return;
    }

    if ((member.getAccessFlags() & (AccessFlags.ACC_ABSTRACT |
            AccessFlags.ACC_NATIVE)) != 0) {
        return;
    }

    ConcreteMethod meth =
        new ConcreteMethod((Method) member, classFile, true, true);

    if (rop) {
        ropDump(meth);
    } else {
        regularDump(meth);
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:27,代码来源:BlockDumper.java


示例2: getCode

import com.android.dx.cf.iface.Method; //导入依赖的package包/类
/**
 * Extracts the code block from the given method of the given class, or
 * <code>null</code>, if method is native or abstract.
 */
private static DalvCode getCode(Method method, DirectClassFile classFile) {
    boolean isNative = AccessFlags.isNative(method.getAccessFlags());
    boolean isStatic = AccessFlags.isStatic(method.getAccessFlags());
    boolean isAbstract = AccessFlags.isAbstract(method.getAccessFlags());

    if (isNative || isAbstract) {
        return null;
    }

    ConcreteMethod concrete = new ConcreteMethod(method, classFile, false, false);
    TranslationAdvice advice = DexTranslationAdvice.THE_ONE;
    RopMethod rmeth = Ropper.convert(concrete, advice);
    CstMethodRef meth = new CstMethodRef(method.getDefiningClass(), method.getNat());
    int paramSize = meth.getParameterWordCount(isStatic);
    DalvCode code = RopTranslator.translate(rmeth, PositionList.NONE, null, paramSize);
    DalvCode.AssignIndicesCallback callback = new DalvCode.AssignIndicesCallback() {
        public int getIndex(Constant cst) {
            // Everything is at index 0!
            return 0;
        }
    };
    code.assignIndices(callback);
    return code;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:29,代码来源:JDKAnalyzer.java


示例3: getExceptions

import com.android.dx.cf.iface.Method; //导入依赖的package包/类
/**
 * Gets the list of thrown exceptions for a given method.
 *
 * @param method {@code non-null;} the method in question
 * @return {@code non-null;} the list of thrown exceptions
 */
public static TypeList getExceptions(Method method) {
    AttributeList attribs = method.getAttributes();
    AttExceptions exceptions = (AttExceptions)
        attribs.findFirst(AttExceptions.ATTRIBUTE_NAME);

    if (exceptions == null) {
        return StdTypeList.EMPTY;
    }

    return exceptions.getExceptions();
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:18,代码来源:AttributeTranslator.java


示例4: getMethodAnnotations

import com.android.dx.cf.iface.Method; //导入依赖的package包/类
/**
 * Gets the annotations out of a given method, similar to {@link
 * #getAnnotations}, also including an annotation for the translation
 * of the method-specific attribute {@code Exceptions}.
 *
 * @param method {@code non-null;} the method in question
 * @return {@code non-null;} the set of annotations, which may be empty
 */
public static Annotations getMethodAnnotations(Method method) {
    Annotations result = getAnnotations(method.getAttributes());
    TypeList exceptions = getExceptions(method);

    if (exceptions.size() != 0) {
        Annotation throwsAnnotation =
            AnnotationUtils.makeThrows(exceptions);
        result = Annotations.combine(result, throwsAnnotation);
    }

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


示例5: getParameterAnnotations

import com.android.dx.cf.iface.Method; //导入依赖的package包/类
/**
 * Gets the parameter annotations out of a given method. This
 * combines both visible and invisible annotations into a single
 * result set.
 *
 * @param method {@code non-null;} the method in question
 * @return {@code non-null;} the list of annotation sets, which may be
 * empty
 */
public static AnnotationsList getParameterAnnotations(Method method) {
    AttributeList attribs = method.getAttributes();
    AttRuntimeVisibleParameterAnnotations visible =
        (AttRuntimeVisibleParameterAnnotations)
        attribs.findFirst(
                AttRuntimeVisibleParameterAnnotations.ATTRIBUTE_NAME);
    AttRuntimeInvisibleParameterAnnotations invisible =
        (AttRuntimeInvisibleParameterAnnotations)
        attribs.findFirst(
                AttRuntimeInvisibleParameterAnnotations.ATTRIBUTE_NAME);

    if (visible == null) {
        if (invisible == null) {
            return AnnotationsList.EMPTY;
        }
        return invisible.getParameterAnnotations();
    }

    if (invisible == null) {
        return visible.getParameterAnnotations();
    }

    // Both are non-null, so combine them.

    return AnnotationsList.combine(visible.getParameterAnnotations(),
            invisible.getParameterAnnotations());
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:37,代码来源:AttributeTranslator.java


示例6: translateAnnotationDefaults

import com.android.dx.cf.iface.Method; //导入依赖的package包/类
/**
 * Gets the {@code AnnotationDefault} attributes out of a
 * given class, if any, reforming them as an
 * {@code AnnotationDefault} annotation.
 *
 * @param cf {@code non-null;} the class in question
 * @return {@code null-ok;} an appropriately-constructed
 * {@code AnnotationDefault} annotation, if there were any
 * annotation defaults in the class, or {@code null} if not
 */
private static Annotation translateAnnotationDefaults(DirectClassFile cf) {
    CstType thisClass = cf.getThisClass();
    MethodList methods = cf.getMethods();
    int sz = methods.size();
    Annotation result =
        new Annotation(thisClass, AnnotationVisibility.EMBEDDED);
    boolean any = false;

    for (int i = 0; i < sz; i++) {
        Method one = methods.get(i);
        AttributeList attribs = one.getAttributes();
        AttAnnotationDefault oneDefault = (AttAnnotationDefault)
            attribs.findFirst(AttAnnotationDefault.ATTRIBUTE_NAME);

        if (oneDefault != null) {
            NameValuePair pair = new NameValuePair(
                    one.getNat().getName(),
                    oneDefault.getValue());
            result.add(pair);
            any = true;
        }
    }

    if (! any) {
        return null;
    }

    result.setImmutable();
    return AnnotationUtils.makeAnnotationDefault(result);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:41,代码来源:AttributeTranslator.java


示例7: process

import com.android.dx.cf.iface.Method; //导入依赖的package包/类
/**
 * Process the given Java Class file and add the classes to the given root.
 * 
 * @param cf
 *            the class file to process
 * @param root
 *            the root element to append the classes to
 * @param referencedTypes
 *            will be filled with the types references in this class file
 * @return the class name for the DEXMLVM file
 */
private TypePlusSuperType process(DirectClassFile cf, Element root,
        Map<String, ReferenceKind> referencedTypes) {
    boolean skeletonOnly = hasSkeletonOnlyAnnotation(cf.getAttributes());
    Element classElement = processClass(cf, root, referencedTypes);
    processFields(cf.getFields(), classElement, referencedTypes, skeletonOnly);

    MethodList methods = cf.getMethods();
    int sz = methods.size();

    for (int i = 0; i < sz; i++) {
        Method one = methods.get(i);

        if (hasIgnoreAnnotation(one.getAttributes())) {
            // If this method has the @XMLVMIgnore annotation, we just
            // simply ignore it.
            continue;
        }

        if (skeletonOnly
                && (one.getAccessFlags() & (AccessFlags.ACC_PRIVATE | AccessFlags.ACC_SYNTHETIC)) != 0) {
            // We only want to generate skeletons. This method is private or
            // synthetic so simply ignore it.
            continue;
        }

        try {
            processMethod(one, cf, classElement, referencedTypes, skeletonOnly);
        } catch (RuntimeException ex) {
            String msg = "...while processing " + one.getName().toHuman() + " "
                    + one.getDescriptor().toHuman();
            throw ExceptionWithContext.withContext(ex, msg);
        }
    }

    String className = classElement.getAttributeValue("name");
    String superClassName = classElement.getAttributeValue("extends");
    return new TypePlusSuperType(className, superClassName);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:50,代码来源:DEXmlvmOutputProcess.java


示例8: ConcreteMethod

import com.android.dx.cf.iface.Method; //导入依赖的package包/类
public ConcreteMethod(Method method, int accessFlags, CstString sourceFile,
        boolean keepLines, boolean keepLocals) {
    this.method = method;
    this.accSuper = (accessFlags & AccessFlags.ACC_SUPER) != 0;
    this.sourceFile = sourceFile;

    AttributeList attribs = method.getAttributes();
    this.attCode = (AttCode) attribs.findFirst(AttCode.ATTRIBUTE_NAME);

    AttributeList codeAttribs = attCode.getAttributes();

    /*
     * Combine all LineNumberTable attributes into one, with the
     * combined result saved into the instance. The following code
     * isn't particularly efficient for doing merges, but as far
     * as I know, this situation rarely occurs "in the
     * wild," so there's not much point in optimizing for it.
     */
    LineNumberList lineNumbers = LineNumberList.EMPTY;
    if (keepLines) {
        for (AttLineNumberTable lnt = (AttLineNumberTable)
                 codeAttribs.findFirst(AttLineNumberTable.ATTRIBUTE_NAME);
             lnt != null;
             lnt = (AttLineNumberTable) codeAttribs.findNext(lnt)) {
            lineNumbers = LineNumberList.concat(lineNumbers,
                    lnt.getLineNumbers());
        }
    }
    this.lineNumbers = lineNumbers;

    LocalVariableList localVariables = LocalVariableList.EMPTY;
    if (keepLocals) {
        /*
         * Do likewise (and with the same caveat) for
         * LocalVariableTable and LocalVariableTypeTable attributes.
         * This combines both of these kinds of attribute into a
         * single LocalVariableList.
         */
        for (AttLocalVariableTable lvt = (AttLocalVariableTable)
                 codeAttribs.findFirst(
                         AttLocalVariableTable.ATTRIBUTE_NAME);
             lvt != null;
             lvt = (AttLocalVariableTable) codeAttribs.findNext(lvt)) {
            localVariables =
                LocalVariableList.concat(localVariables,
                        lvt.getLocalVariables());
        }

        LocalVariableList typeList = LocalVariableList.EMPTY;
        for (AttLocalVariableTypeTable lvtt = (AttLocalVariableTypeTable)
                 codeAttribs.findFirst(
                         AttLocalVariableTypeTable.ATTRIBUTE_NAME);
             lvtt != null;
             lvtt =
                 (AttLocalVariableTypeTable) codeAttribs.findNext(lvtt)) {
            typeList =
                LocalVariableList.concat(typeList,
                        lvtt.getLocalVariables());
        }

        if (typeList.size() != 0) {
            localVariables =
                LocalVariableList.mergeDescriptorsAndSignatures(
                        localVariables, typeList);
        }
    }
    this.localVariables = localVariables;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:69,代码来源:ConcreteMethod.java


示例9: endParsingMember

import com.android.dx.cf.iface.Method; //导入依赖的package包/类
public void endParsingMember(ByteArray bytes, int offset, String name,
                             String descriptor, Member member) {
    if (!(member instanceof Method)) {
        return;
    }

    if (!shouldDumpMethod(name)) {
        return;
    }

    ConcreteMethod meth = new ConcreteMethod((Method) member, classFile,
                                             true, true);

    TranslationAdvice advice = DexTranslationAdvice.THE_ONE;
    RopMethod rmeth =
        Ropper.convert(meth, advice, classFile.getMethods());

    if (optimize) {
        boolean isStatic = AccessFlags.isStatic(meth.getAccessFlags());
        rmeth = Optimizer.optimize(rmeth,
                BaseDumper.computeParamWidth(meth, isStatic), isStatic,
                true, advice);
    }

    System.out.println("digraph "  + name + "{");

    System.out.println("\tfirst -> n"
            + Hex.u2(rmeth.getFirstLabel()) + ";");

    BasicBlockList blocks = rmeth.getBlocks();

    int sz = blocks.size();
    for (int i = 0; i < sz; i++) {
        BasicBlock bb = blocks.get(i);
        int label = bb.getLabel();
        IntList successors = bb.getSuccessors();

        if (successors.size() == 0) {
            System.out.println("\tn" + Hex.u2(label) + " -> returns;");
        } else if (successors.size() == 1) {
            System.out.println("\tn" + Hex.u2(label) + " -> n"
                    + Hex.u2(successors.get(0)) + ";");
        } else {
            System.out.print("\tn" + Hex.u2(label) + " -> {");
            for (int j = 0; j < successors.size(); j++ ) {
                int successor = successors.get(j);

                if (successor != bb.getPrimarySuccessor()) {
                    System.out.print(" n" + Hex.u2(successor) + " ");
                }

            }
            System.out.println("};");

            System.out.println("\tn" + Hex.u2(label) + " -> n"
                    + Hex.u2(bb.getPrimarySuccessor())
                    + " [label=\"primary\"];");


        }
    }

    System.out.println("}");
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:65,代码来源:DotDumper.java


示例10: endParsingMember

import com.android.dx.cf.iface.Method; //导入依赖的package包/类
public void endParsingMember(ByteArray bytes, int offset, String name,
                             String descriptor, Member member) {
    if (!(member instanceof Method)) {
        return;
    }

    if (!shouldDumpMethod(name)) {
        return;
    }

    ConcreteMethod meth = new ConcreteMethod((Method) member, classFile,
                                             true, true);

    TranslationAdvice advice = DexTranslationAdvice.THE_ONE;
    RopMethod rmeth =
        Ropper.convert(meth, advice);

    if (optimize) {
        boolean isStatic = AccessFlags.isStatic(meth.getAccessFlags());
        rmeth = Optimizer.optimize(rmeth,
                BaseDumper.computeParamWidth(meth, isStatic), isStatic,
                true, advice);
    }

    System.out.println("digraph "  + name + "{");

    System.out.println("\tfirst -> n"
            + Hex.u2(rmeth.getFirstLabel()) + ";");

    BasicBlockList blocks = rmeth.getBlocks();

    int sz = blocks.size();
    for (int i = 0; i < sz; i++) {
        BasicBlock bb = blocks.get(i);
        int label = bb.getLabel();
        IntList successors = bb.getSuccessors();

        if (successors.size() == 0) {
            System.out.println("\tn" + Hex.u2(label) + " -> returns;");
        } else if (successors.size() == 1) {
            System.out.println("\tn" + Hex.u2(label) + " -> n"
                    + Hex.u2(successors.get(0)) + ";");
        } else {
            System.out.print("\tn" + Hex.u2(label) + " -> {");
            for (int j = 0; j < successors.size(); j++ ) {
                int successor = successors.get(j);

                if (successor != bb.getPrimarySuccessor()) {
                    System.out.print(" n" + Hex.u2(successor) + " ");
                }

            }
            System.out.println("};");

            System.out.println("\tn" + Hex.u2(label) + " -> n"
                    + Hex.u2(bb.getPrimarySuccessor())
                    + " [label=\"primary\"];");


        }
    }

    System.out.println("}");
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:65,代码来源:DotDumper.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java CreateApplicationVersionRequest类代码示例发布时间:2022-05-22
下一篇:
Java DataObjectRelationship类代码示例发布时间: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