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

Java DexBackedMethod类代码示例

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

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



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

示例1: compare

import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
private static boolean compare(DexBackedMethod dexBackedMethod, DexBackedMethod sDexBackedMethod) {
    if (dexBackedMethod == null || sDexBackedMethod == null || dexBackedMethod.getName() == null || sDexBackedMethod.getName() == null) {
        return false;
    }
    if (dexBackedMethod.getName().equals(sDexBackedMethod.getName())) {
        List<String> parameters = dexBackedMethod.getParameterTypes();
        List<String> sParameters = sDexBackedMethod.getParameterTypes();
        if (parameters.size() != sParameters.size()) {
            return false;
        }
        for (String param : parameters) {
            if (!sParameters.contains(param)) {
                return false;
            }
        }
        return true;
    }
    return false;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:20,代码来源:SmaliDiffUtils.java


示例2: filterMethod

import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
@Override
public boolean filterMethod(MethodDiffInfo methodDiffInfo) throws PatchException {
    DexBackedMethod dexBackedMethod = methodDiffInfo.getBackedMethod();
    if (dexBackedMethod.getName().equals("<clinit>") || dexBackedMethod.getName().contains("ajc$preClinit")||dexBackedMethod.getName().equals("<init>")||dexBackedMethod.getName().contains("access$")) {
        return true;
    }

    if (methodDiffInfo.getType().equals(DiffType.REMOVE)) {
        return true;
    } else if (methodDiffInfo.getType().equals(DiffType.ADD)){
        throw new PatchException("can't add method:" + dexBackedMethod.getName() + " in class:" + dexBackedMethod.getDefiningClass());
    }

    if (dexBackedMethod.getParameters().size() > 8) {
        throw new PatchException("can't patch method:" + dexBackedMethod.getName() + "has Parameters above 8 in class:"+dexBackedMethod.getDefiningClass());
    }
    if (dexBackedMethod.getParameterTypes().contains("J") || dexBackedMethod.getParameterTypes().contains("D") || dexBackedMethod.getParameterTypes().contains("F")) {
       throw new PatchException("can't patch method:" + dexBackedMethod.getName() + "has ParameterType long,double or float in class:"+dexBackedMethod.getDefiningClass());
    }
    return false;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:22,代码来源:AndFixFilterImpl.java


示例3: DexMethod

import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
public DexMethod(DexBackedMethod method, boolean fullMethodSignatures) {
    this.fullMethodSignatures = fullMethodSignatures;

    this.method = method;
    opCounts = new TObjectIntHashMap<>();
    apiCounts = new TObjectIntHashMap<>();
    stringReferenceCounts = new TObjectIntHashMap<>();
    fieldReferenceCounts = new TObjectIntHashMap<>();
    annotationCount = method.getAnnotations().size();
    if (method.getImplementation() != null) {
        analyze(method.getImplementation());
    }
    methodAccessors = buildAccessors(method.getAccessFlags());
}
 
开发者ID:CalebFenton,项目名称:apkfile,代码行数:15,代码来源:DexMethod.java


示例4: analyze

import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
private void analyze() {
    fieldCount = Utils.makeCollection(classDef.getFields()).size();
    for (DexBackedMethod dbm : classDef.getMethods()) {
        DexMethod dexMethod;
        try {
            dexMethod = new DexMethod(dbm, fullMethodSignatures);
            failedMethods += 1;
        } catch (Exception e) {
            Logger.warn("Failed to analyze method: " + ReferenceUtil.getMethodDescriptor(dbm) + "; skipping", e);
            continue;
        }
        String methodDescriptor = ReferenceUtil.getMethodDescriptor(dbm);
        String methodSignature = methodDescriptor.split("->", 2)[1];
        methodSignatureToMethod.put(methodSignature, dexMethod);

        Utils.rollUp(opCounts, dexMethod.getOpCounts());
        Utils.rollUp(apiCounts, dexMethod.getApiCounts());
        Utils.rollUp(stringReferenceCounts, dexMethod.getStringReferenceCounts());
        Utils.rollUp(fieldReferenceCounts, dexMethod.getFieldReferenceCounts());
        Utils.rollUp(methodAccessorCounts, dexMethod.getMethodAccessors());

        annotationCount += dexMethod.getAnnotationCount();
        registerCount += dexMethod.getRegisterCount();
        instructionCount += dexMethod.getInstructionCount();
        tryCatchCount += dexMethod.getTryCatchCount();
        debugItemCount += dexMethod.getDebugItemCount();
        cyclomaticComplexity += dexMethod.getCyclomaticComplexity();
    }
    if (!methodSignatureToMethod.isEmpty()) {
        cyclomaticComplexity /= methodSignatureToMethod.size();
    }
}
 
开发者ID:CalebFenton,项目名称:apkfile,代码行数:33,代码来源:DexClass.java


示例5: getMethodAnnotaionPrepareClasses

import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
public static void getMethodAnnotaionPrepareClasses(DexDiffInfo dexDiffInfo, Set<String> prepareclasses){

        for (DexBackedMethod method:dexDiffInfo.getModifiedMethods()){
            Set<? extends Annotation>annotations = method.getAnnotations();
            if (annotations == null){
                continue;
            }
            for (Annotation annotation:annotations){
                String type = annotation.getType();
                if (type!= null&&type.startsWith("L")&&type.endsWith(";")){
                    prepareclasses.add(type.substring(1, type.length() - 1).replace('/', '.'));
                    System.out.println("prepare class: " + type);
                }
                Set<? extends AnnotationElement> elements = annotation.getElements();
                for (AnnotationElement dexBackedAnnotationElement:elements){
                    if (dexBackedAnnotationElement.getValue() instanceof DexBackedArrayEncodedValue){
                        List<? extends EncodedValue> values = ((DexBackedArrayEncodedValue) dexBackedAnnotationElement.getValue()).getValue();
                        for (EncodedValue encodedValue:values) {
                            if (encodedValue instanceof TypeEncodedValue) {
                                prepareclasses.add(((TypeEncodedValue) encodedValue).getValue().substring(1, ((TypeEncodedValue) encodedValue).getValue().length() - 1).replace('/', '.'));
                                System.out.println("prepare class: " + ((TypeEncodedValue) encodedValue).getValue());
                            }
                        }

                    }else if (dexBackedAnnotationElement.getValue() instanceof DexBackedTypeEncodedValue){
                        String value = ((DexBackedTypeEncodedValue) dexBackedAnnotationElement.getValue()).getValue();
                        prepareclasses.add(value.substring(1, value.length() - 1).replace('/', '.'));
                        System.out.println("prepare class: " + value);
                    }
                }
            }
        }

    }
 
开发者ID:alibaba,项目名称:atlas,代码行数:35,代码来源:ApkPatch.java


示例6: addModifiedMethods

import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
public void addModifiedMethods(DexBackedMethod method) throws PatchException {
    System.out.println("add modified Method:" + method.getReturnType()
            + "  " + method.getName() + "("
            + Formater.formatStringList(method.getParameterTypes())
            + ")  in Class:" + method.getDefiningClass());
    this.modifiedMethods.add(method);

    if (!modifiedClasses.contains(method.classDef)) {
        modifiedClasses.add(method.classDef);
        String className = method.classDef.getType();
        addManifestModifiedClass(className);
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:14,代码来源:DexDiffInfo.java


示例7: getMethod

import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
private static DexBackedMethod getMethod(
                            DexBackedClassDef classDef,
                            String methodName) {

     for (DexBackedMethod method : classDef.getVirtualMethods()) {

        String matchName = method.getName();
        if (matchName.equals(methodName)) {
            return method;
        }
    }

    return null;
}
 
开发者ID:android-dtf,项目名称:core_generate_aidl,代码行数:15,代码来源:App.java


示例8: getMethod

import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
public DexBackedMethod getMethod() {
    return method;
}
 
开发者ID:CalebFenton,项目名称:apkfile,代码行数:4,代码来源:DexMethod.java


示例9: buildPrepareClass

import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
private static Set<String> buildPrepareClass(File smaliDir, List<File> newFiles,
                                                 DexDiffInfo info) throws PatchException {
        Set<DexBackedClassDef> classes = Sets.newHashSet();
        classes = SmaliDiffUtils.scanClasses(smaliDir, newFiles);
        ArrayList<String> methods = new ArrayList<String>();
        {
            Set<DexBackedMethod> tempSet = info.getModifiedMethods();
            for (DexBackedMethod methodRef : tempSet) {
                String template = methodRef.getDefiningClass() + "->" + methodRef.getName();
                methods.add(template);
                System.out.println("template: " + template);
                if (superClasses.containsKey(methodRef.getDefiningClass())) {
                    ArrayList<String> derivedClasses = superClasses.get(methodRef.getDefiningClass());
                    for (int i = 0; i < derivedClasses.size(); i++) {
                        template = derivedClasses.get(i) + "->" + methodRef.getName();
                        System.out.println("template: " + template);
                        methods.add(template);
                    }
                }
            }
        }

        Set<String> prepareClasses = new HashSet<String>();
        try {
            final ClassFileNameHandler inFileNameHandler = new ClassFileNameHandler(smaliDir, ".smali");
            for (DexBackedClassDef classDef : classes) {
                currentClassType = null;
                String className = TypeGenUtil.newType(classDef.getType());
                // baksmali.disassembleClass(classDef, outFileNameHandler, options);
                File smaliFile = inFileNameHandler.getUniqueFilenameForClass(className);
                if (!smaliFile.exists()){
                    continue;
                }
                //增加class注解到prepare
                getClassAnnotaionPrepareClasses(classDef,prepareClasses,info);

                BufferedReader br = new BufferedReader(new FileReader(smaliFile));
                String data = br.readLine();// 一次读入一行,直到读入null为文件结束
                while (data != null) {
                    boolean find = false;
                    for (String m : methods) {
                        if (data.contains(m)) {
                            find = true;
                            break;
                        }
                    }
                    if (find) {
                        prepareClasses.add(className.substring(1, className.length() - 1).replace('/', '.'));
                        System.out.println("prepare class: " + className);
                        break;
                    }
                    data = br.readLine(); // 接着读下一行
                }
                br.close();

            }
        } catch (Exception e) {
            throw new PatchException(e);
        }
        for (DexBackedMethod method:info.getModifiedMethods()) {
            prepareClasses.add(method.getDefiningClass().substring(1, method.getDefiningClass().length() - 1).replace("/", "."));
        }
        //增加modify的anatation到prepare
//        getMethodAnnotaionPrepareClasses(info,prepareClasses);
        return prepareClasses;
    }
 
开发者ID:alibaba,项目名称:atlas,代码行数:67,代码来源:ApkPatch.java


示例10: getBackedMethod

import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
public DexBackedMethod getBackedMethod() {
    return backedMethod;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:4,代码来源:MethodDiffInfo.java


示例11: setBackedMethod

import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
public void setBackedMethod(DexBackedMethod backedMethod) {
    this.backedMethod = backedMethod;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:4,代码来源:MethodDiffInfo.java


示例12: getModifiedMethods

import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
public Set<DexBackedMethod> getModifiedMethods() {
    return modifiedMethods;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:4,代码来源:DexDiffInfo.java


示例13: getAddedMethods

import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
public Set<DexBackedMethod> getAddedMethods() {
    return addedMethods;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:4,代码来源:DexDiffInfo.java


示例14: addMethod

import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
public void addMethod(int transactionId, String methodName, DexBackedMethod method) {

        String dottedReturnType = Utils.descriptorToDot(method.getReturnType());

        /* Update imports for return type */
        this.addImport(dottedReturnType);

        String shortReturnType = Utils.getShort(dottedReturnType);

        /* Args */
        String paramString = makeParamString(method);

        String methodString = "    " + shortReturnType + " " + methodName + "(" + paramString + ");";

        /* Add to the array list */
        this.methods.put(transactionId, methodString);
    }
 
开发者ID:android-dtf,项目名称:core_generate_aidl,代码行数:18,代码来源:AidlFile.java


示例15: processDex

import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
private static int processDex(String outputDirectory) {

        int rtn = 0;
        int i = 0;

        Set<? extends DexBackedClassDef> classDefs = gDexFile.getClasses();

        /* Find all IInterfaces first */
        for (DexBackedClassDef classDef: classDefs) {

            String className = Utils.descriptorToDot(classDef.getType());

            /* No support AIDL */
            if (className.startsWith("android.support")) {
                continue;
            }

            SortedSet<String> interfaces = new TreeSet(classDef.getInterfaces());
            if (interfaces.size() != 1) {
                continue;           
            }

            /* Getting here is a valid AIDL (or so we think) */
            if (Utils.descriptorToDot(interfaces.first()).equals(IINTERFACE_CLASS)) {

                /* First find the Stub and get a list of transactions */
                String stubName = className + ".Stub";
                String stubProxyName = className + ".Stub.Proxy";

                DexBackedClassDef stubDef = getClassDef(classDefs, stubName);
                DexBackedClassDef stubProxyDef = getClassDef(classDefs, stubProxyName);

                if (stubDef == null) {
                    System.err.println("[ERROR] Unable to find Stub for class: "
                                                            + stubName + ", Skiping!");
                    continue;
                }

                if (stubProxyDef == null) {
                    System.err.println("[ERROR] Unable to find Stub.Proxy for class: "
                                                            + stubProxyName + ", Skiping!");
                    continue;
                }

                AidlFile aidl = new AidlFile(className, outputDirectory);

                /* Next, we need all the transactions for this. */
                for (DexBackedField field : stubDef.getStaticFields()) {
                    if (field.getName().startsWith("TRANSACTION_")) {

                        String methodName = field.getName().replace("TRANSACTION_", "");

                        /* Transaction ID for sorting */
                        EncodedValue iiev = field.getInitialValue();
                        int transactionId = ((IntEncodedValue) iiev).getValue();

                        /* Get the Stub.Proxy method (which has return + args) */
                        DexBackedMethod method = getMethod(stubProxyDef, methodName);

                        aidl.addMethod(transactionId, methodName, method);
                    }
                }

                /* Write it out. */
                aidl.writeFile();
            }
        }

        return rtn;
    }
 
开发者ID:android-dtf,项目名称:core_generate_aidl,代码行数:71,代码来源:App.java


示例16: makeParamString

import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
private String makeParamString(DexBackedMethod method) {

        StringBuilder paramStringBuilder = new StringBuilder();
        int paramOffset = 0;

        for (MethodParameter param : method.getParameters()) {

            String dottedReturnName = Utils.descriptorToDot(param.getType());

            this.addImport(dottedReturnName);

            String shortName = Utils.getShort(dottedReturnName);

            String argName = "";

            /* Is the name saved? */
            if (param.getName() != null) {
                argName = param.getName();
            } else {
                argName = "arg" + Integer.toString(paramOffset);
            }

            paramStringBuilder.append(shortName + " " + argName + ", ");
            paramOffset++;
        }

        return paramStringBuilder.toString().replaceAll(",\\s$", "");
    }
 
开发者ID:android-dtf,项目名称:core_generate_aidl,代码行数:29,代码来源:AidlFile.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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