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


Java ImmutableMethod类代码示例

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


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

示例1: reDexMethods

import org.jf.dexlib2.immutable.ImmutableMethod; //导入依赖的package包/类
private static List<Method> reDexMethods(@Nonnull ClassDef classDef) {
    List<Method> taintedMethods = Lists.newArrayList();
    for (Method method : classDef.getMethods()) {
        MethodImplementation implementation = method.getImplementation();
        MutableMethodImplementation mutableImplementation = new MutableMethodImplementation(implementation);
        taintedMethods.add(new ImmutableMethod(
                method.getDefiningClass(),
                method.getName(),
                method.getParameters(),
                method.getReturnType(),
                method.getAccessFlags(),
                method.getAnnotations(),
                mutableImplementation));
    }
    return taintedMethods;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:17,代码来源:PatchFieldTool.java

示例2: customizeClass

import org.jf.dexlib2.immutable.ImmutableMethod; //导入依赖的package包/类
private ClassDef customizeClass(ClassDef classDef) {
    List<Method> methods = new ArrayList<>();
    boolean modifiedMethod = false;
    for (Method method : classDef.getMethods()) {
        MethodImplementation implementation = method.getImplementation();
        if (implementation == null) {
            methods.add(method);
            continue;
        }
        MethodImplementation customImpl = searchAndReplaceInvocations(implementation);
        if (customImpl==implementation) {
            methods.add(method);
            continue;
        }
        modifiedMethod = true;
        final ImmutableMethod newMethod = new ImmutableMethod(method.getDefiningClass(),
                                                              method.getName(),
                                                              method.getParameters(),
                                                              method.getReturnType(),
                                                              method.getAccessFlags(),
                                                              method.getAnnotations(),
                                                              customImpl);
        methods.add(newMethod);
    }
    if (!modifiedMethod)
        return classDef;
    return new ImmutableClassDef(classDef.getType(),
                                 classDef.getAccessFlags(),
                                 classDef.getSuperclass(),
                                 classDef.getInterfaces(),
                                 classDef.getSourceFile(),
                                 classDef.getAnnotations(),
                                 classDef.getFields(),
                                 methods);
}
 
开发者ID:packmad,项目名称:RmPerm,代码行数:36,代码来源:BytecodeCustomizer.java

示例3: reMethod

import org.jf.dexlib2.immutable.ImmutableMethod; //导入依赖的package包/类
@Override
public Method reMethod(Method method) {
    String newType = null;
    boolean isBasic = false;
    boolean isInit = false;
    boolean changeOpcode = false;
    String methodName = method.getName();
    String returnType = method.getReturnType();
    MethodImplementation methodImplementation = method.getImplementation();
    List<? extends MethodParameter> paramters = method.getParameters();
    if (methodName.equals("<init>") || methodName.equals("<cinit>")) {
        isInit = true;
    }


    if (basicType.containsKey(returnType)) {
        newType = returnType;
        isBasic = true;
    } else {
        newType = classProcessor.classProcess(DefineUtils.getDalvikClassName(returnType)).className;
    }

    String[] argsOringn = new String[paramters.size()];
    String[] args = new String[paramters.size()];
    for (int i = 0; i < paramters.size(); i++) {
        //型参数不混淆
        if (basicType.containsKey(paramters.get(i).getType())) {
            argsOringn[i] = basicType.get(paramters.get(i).getType());
            args[i] = argsOringn[i];
            continue;
        }
        argsOringn[i] = DefineUtils.getDalvikClassName(paramters.get(i).getType());
        args[i] = classProcessor.classProcess(DefineUtils.getDalvikClassName(paramters.get(i).getType())).className;
    }
    String type = method.getReturnType();
    
    return new ImmutableMethod(reType,
            classProcessor.methodProcess(isInit ? methodName :
                    DefineUtils.getDalvikClassName(method.getDefiningClass()), methodName, isBasic ? basicType.get(returnType) : DefineUtils.getDalvikClassName(returnType), StringUtils.join(argsOringn, ",")).methodName,
            reParameters(paramters),
            isBasic ? newType:
                    DefineUtils.getDefineClassName(newType,type.startsWith("[")),
                method.getAccessFlags(),
            getAnnotation(method.getAnnotations()),
            reMethodImpl(methodImplementation));

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

示例4: modifyMethod

import org.jf.dexlib2.immutable.ImmutableMethod; //导入依赖的package包/类
public static void modifyMethod(String srcDexFile, String outDexFile, boolean isAndFix) throws IOException {

        DexFile dexFile = DexFileFactory.loadDexFile(srcDexFile, 15, true);

        final Set<ClassDef> classes = Sets.newConcurrentHashSet();

        for (ClassDef classDef : dexFile.getClasses()) {
            Set<Method> methods = Sets.newConcurrentHashSet();
            boolean modifiedMethod = false;
            for (Method method : classDef.getMethods()) {
                    MethodImplementation implementation = method.getImplementation();
                    if (implementation != null&&(methodNeedsModification(classDef, method, isAndFix))) {
                        modifiedMethod = true;
                        methods.add(new ImmutableMethod(
                                method.getDefiningClass(),
                                method.getName(),
                                method.getParameters(),
                                method.getReturnType(),
                                method.getAccessFlags(),
                                method.getAnnotations(),
                                isAndFix ?
                                        modifyMethodAndFix(implementation, method) : modifyMethodTpatch(implementation, method)));
                    } else {
                        methods.add(method);
                    }
                }
            if (!modifiedMethod) {
                classes.add(classDef);
            } else {
                classes.add(new ImmutableClassDef(
                        classDef.getType(),
                        classDef.getAccessFlags(),
                        classDef.getSuperclass(),
                        classDef.getInterfaces(),
                        classDef.getSourceFile(),
                        classDef.getAnnotations(),
                        classDef.getFields(),
                        methods));
            }

        }

        DexFileFactory.writeDexFile(outDexFile, new DexFile() {
            @Nonnull
            @Override
            public Set<? extends ClassDef> getClasses() {
                return new AbstractSet<ClassDef>() {
                    @Nonnull
                    @Override
                    public Iterator<ClassDef> iterator() {
                        return classes.iterator();
                    }

                    @Override
                    public int size() {
                        return classes.size();
                    }
                };
            }
        });
    }
 
开发者ID:alibaba,项目名称:atlas,代码行数:62,代码来源:PatchMethodTool.java

示例5: inlineMethod

import org.jf.dexlib2.immutable.ImmutableMethod; //导入依赖的package包/类
@Nonnull
private static Method inlineMethod(int accessFlags, @Nonnull String cls, @Nonnull String name,
                                   @Nonnull String params, @Nonnull String returnType) {
    ImmutableList<ImmutableMethodParameter> paramList = ImmutableList.copyOf(ParamUtil.parseParamString(params));
    return new ImmutableMethod(cls, name, paramList, returnType, accessFlags, null, null);
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:7,代码来源:InlineMethodResolver.java

示例6: inlineMethod

import org.jf.dexlib2.immutable.ImmutableMethod; //导入依赖的package包/类
private static Method inlineMethod(int accessFlags,  String cls,  String name,
                                    String params,  String returnType) {
    ImmutableList<ImmutableMethodParameter> paramList = ImmutableList.copyOf(ParamUtil.parseParamString(params));
    return new ImmutableMethod(cls, name, paramList, returnType, accessFlags, null, null);
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:6,代码来源:InlineMethodResolver.java

示例7: addMethod

import org.jf.dexlib2.immutable.ImmutableMethod; //导入依赖的package包/类
public static void addMethod(String srcDexFile, String outDexFile, DexBackedClassDef dexBackedClassDef, ImmutableMethod immutableMethod) throws IOException {


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


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