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


Java ClassDef类代码示例

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


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

示例1: writeRawDexSingleThread

import org.jf.dexlib2.iface.ClassDef; //导入依赖的package包/类
static void writeRawDexSingleThread(DexDataStore dataStore, DexFile dexFile, int maxDexPoolSize,
		DexIO.Logger logger, File file) throws IOException {
	Set<? extends ClassDef> classes = dexFile.getClasses();
	Iterator<? extends ClassDef> classIterator = classes.iterator();
	DexPool dexPool = new DexPool(dexFile.getOpcodes());
	int classCount = 0;
	while (classIterator.hasNext()) {
		ClassDef classDef = classIterator.next();
		dexPool.internClass(classDef);
		if (getDexPoolOverflow(dexPool, maxDexPoolSize)) {
			handleDexPoolOverflow(classDef, classCount, classes.size());
			throw new AssertionError("unexpected type count");
		}
		classCount++;
	}
	if (logger != null) logger.log(file, SingletonDexContainer.UNDEFINED_ENTRY_NAME, classCount);
	dexPool.writeTo(dataStore);
}
 
开发者ID:DexPatcher,项目名称:multidexlib2,代码行数:19,代码来源:DexIO.java

示例2: createBaksmaliOptions

import org.jf.dexlib2.iface.ClassDef; //导入依赖的package包/类
/**
 * 生成解析成smali代码的选项
 *
 * @return
 */
private static baksmaliOptions createBaksmaliOptions(ClassDef classDef) {
    baksmaliOptions options = new baksmaliOptions();
    options.deodex = false;
    options.noParameterRegisters = false;
    options.useLocalsDirective = true;
    options.useSequentialLabels = true;
    options.outputDebugInfo = false;
    options.addCodeOffsets = false;
    options.jobs = -1;
    options.noAccessorComments = false;
    options.registerInfo = 0;// 128
    options.ignoreErrors = false;
    options.inlineResolver = null;
    options.checkPackagePrivateAccess = false;
    options.apiLevel = DEFAULT_API_LEVEL;
    List<ClassDef> classDefs = Lists.newArrayList();
    classDefs.add(classDef);
    options.syntheticAccessorResolver = new SyntheticAccessorResolver(classDefs);
    return options;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:26,代码来源:SmaliCodeUtils.java

示例3: getBuildOption

import org.jf.dexlib2.iface.ClassDef; //导入依赖的package包/类
public static baksmaliOptions getBuildOption(Iterable<? extends ClassDef> collection, int apiLevel) {
    baksmaliOptions options = new baksmaliOptions();

    options.deodex = false;
    options.noParameterRegisters = false;
    options.useLocalsDirective = true;
    options.useSequentialLabels = true;
    options.outputDebugInfo = true;
    options.addCodeOffsets = false;
    options.jobs = -1;
    options.noAccessorComments = false;
    options.registerInfo = 0;// 128
    options.ignoreErrors = false;
    options.inlineResolver = null;
    options.apiLevel = apiLevel;
    options.checkPackagePrivateAccess = false;
    if (!options.noAccessorComments) {
        options.syntheticAccessorResolver = new SyntheticAccessorResolver(collection);
    }

    return options;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:23,代码来源:SmaliDiffUtils.java

示例4: createModifyClasses

import org.jf.dexlib2.iface.ClassDef; //导入依赖的package包/类
@Override
public Set<ClassDef> createModifyClasses() throws IOException, PatchException {
    dexDiffer.setTpatch(false);
    Set<ClassDef>mClasses =  super.createModifyClasses();
    if (hotClassList == null || hotClassList.size() == 0){
        return mClasses;
    }
    hotClassDefs = new HashSet<>();
    Iterator<ClassDef>iterator = mClasses.iterator();
    while (iterator.hasNext()) {
        ClassDef classDef = iterator.next();
        if (hotClassList.contains(classDef.getType()) || hotClassList.contains(SmaliUtils.getDalvikClassName(classDef.getType()))) {
                hotClassDefs.add(classDef);
                iterator.remove();
            }
    }
    return mClasses;

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

示例5: PatchDexTool

import org.jf.dexlib2.iface.ClassDef; //导入依赖的package包/类
public PatchDexTool(List<File> baseDexFiles, List<File> newDexFiles, int apiLevel, Map<String,ClassDef> map,boolean mainBundle) {
    this.baseDexFiles = baseDexFiles;
    this.newDexFiles = newDexFiles;
    this.apiLevel = apiLevel;
    this.mainBundle = mainBundle;
    assert (null != baseDexFiles && baseDexFiles.size() > 0);
    assert (null != newDexFiles && newDexFiles.size() > 0);
    this.dexDiffer = new DexDiffer(baseDexFiles, newDexFiles, apiLevel);
    if (map == null) {
        dexDiffer.setLastBundleClassMap(lastBundleClassMap);
    }else {
        dexDiffer.setLastBundleClassMap(map);
    }


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

示例6: writeDex

import org.jf.dexlib2.iface.ClassDef; //导入依赖的package包/类
public void writeDex(File outDexFile,Set<ClassDef>classDefs) throws IOException {

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

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

示例7: getTpatchClassDef

import org.jf.dexlib2.iface.ClassDef; //导入依赖的package包/类
public static void getTpatchClassDef(File tpatchFile, Map<String, Map<String, ClassDef>> bundleMap) throws IOException {
    if (tpatchFile == null || !tpatchFile.exists()) {
        return;
    }
    File unZipFolder = new File(tpatchFile.getParentFile(), tpatchFile.getName().split("\\.")[0]);
    unZipFolder.mkdirs();
    ZipUtils.unzip(tpatchFile, unZipFolder.getAbsolutePath());
    File[] bundleFolder = unZipFolder.listFiles(new FileFilter() {
        @Override
        public boolean accept(File pathname) {
            return pathname.isDirectory() && pathname.getName().startsWith("lib");
        }
    });

    for (File file : bundleFolder) {
        Map<String, ClassDef> dexClasses = getBundleClassDef(file);
        bundleMap.put(file.getName(), dexClasses);

    }

    FileUtils.deleteDirectory(tpatchFile.getParentFile());
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:23,代码来源:PatchUtils.java

示例8: of

import org.jf.dexlib2.iface.ClassDef; //导入依赖的package包/类
public static ImmutableClassDef of(ClassDef classDef) {
    if (classDef instanceof ImmutableClassDef) {
        return (ImmutableClassDef)classDef;
    }
    return new ImmutableClassDef(
            classDef.getType(),
            classDef.getAccessFlags(),
            classDef.getSuperclass(),
            classDef.getInterfaces(),
            classDef.getSourceFile(),
            classDef.getAnnotations(),
            classDef.getStaticFields(),
            classDef.getInstanceFields(),
            classDef.getDirectMethods(),
            classDef.getVirtualMethods());
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:17,代码来源:ImmutableClassDef.java

示例9: canAccess

import org.jf.dexlib2.iface.ClassDef; //导入依赖的package包/类
public static boolean canAccess( TypeProto type,  Method virtualMethod, boolean checkPackagePrivate,
                                boolean checkProtected, boolean checkClass) {
    if (checkPackagePrivate && MethodUtil.isPackagePrivate(virtualMethod)) {
        String otherPackage = TypeUtils.getPackage(virtualMethod.getDefiningClass());
        String thisPackage = TypeUtils.getPackage(type.getType());
        if (!otherPackage.equals(thisPackage)) {
            return false;
        }
    }

    if (checkProtected && (virtualMethod.getAccessFlags() & AccessFlags.PROTECTED.getValue()) != 0) {
        if (!TypeProtoUtils.extendsFrom(type, virtualMethod.getDefiningClass())) {
            return false;
        }
    }

    if (checkClass) {
        ClassPath classPath = type.getClassPath();
        ClassDef methodClassDef = classPath.getClassDef(virtualMethod.getDefiningClass());
        if (!TypeUtils.canAccessClass(type.getType(), methodClassDef)) {
            return false;
        }
    }

    return true;
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:27,代码来源:AnalyzedMethodUtil.java

示例10: canAccess

import org.jf.dexlib2.iface.ClassDef; //导入依赖的package包/类
public static boolean canAccess(@Nonnull TypeProto type, @Nonnull Method virtualMethod, boolean checkPackagePrivate,
                                boolean checkProtected, boolean checkClass) {
    if (checkPackagePrivate && MethodUtil.isPackagePrivate(virtualMethod)) {
        String otherPackage = TypeUtils.getPackage(virtualMethod.getDefiningClass());
        String thisPackage = TypeUtils.getPackage(type.getType());
        if (!otherPackage.equals(thisPackage)) {
            return false;
        }
    }

    if (checkProtected && (virtualMethod.getAccessFlags() & AccessFlags.PROTECTED.getValue()) != 0) {
        if (!TypeProtoUtils.extendsFrom(type, virtualMethod.getDefiningClass())) {
            return false;
        }
    }

    if (checkClass) {
        ClassPath classPath = type.getClassPath();
        ClassDef methodClassDef = classPath.getClassDef(virtualMethod.getDefiningClass());
        if (!TypeUtils.canAccessClass(type.getType(), methodClassDef)) {
            return false;
        }
    }

    return true;
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:27,代码来源:AnalyzedMethodUtil.java

示例11: customizeBytecode

import org.jf.dexlib2.iface.ClassDef; //导入依赖的package包/类
private File customizeBytecode(Map<MethodReference, Set<String>> apiToPermissions,
                               Map<MethodReference, MethodReference> redirections,
                               List<ClassDef> customClasses
) throws IOException {
    File tmpClassesDex = File.createTempFile("NewClasseDex", null);
    tmpClassesDex.deleteOnExit();
    BytecodeCustomizer c = new BytecodeCustomizer(
            apiToPermissions,
            redirections,
            customClasses,
            new File(inApkFilename),
            tmpClassesDex,
            out,
            noAutoRemoveVoid,
            removeAds
    );
    c.customize();
    return tmpClassesDex;
}
 
开发者ID:packmad,项目名称:RmPerm,代码行数:20,代码来源:RmPermissions.java

示例12: getTargetId

import org.jf.dexlib2.iface.ClassDef; //导入依赖的package包/类
@Override
protected String getTargetId(String patchId, ClassDef patch, PatcherAnnotation annotation) {
	String targetId = patchId;
	String target = annotation.getTarget();
	String targetClass = annotation.getTargetClass();
	if (target != null || targetClass != null) {
		String targetDescriptor;
		if (target != null) {
			if (DexUtils.isClassDescriptor(target)) {
				targetDescriptor = target;
			} else {
				String base = TypeName.fromClassDescriptor(patch.getType());
				targetDescriptor = TypeName.toClassDescriptor(resolveTarget(target, base));
			}
		} else {
			targetDescriptor = targetClass;
		}
		targetId = Id.fromClassDescriptor(targetDescriptor);
	}
	if (shouldLogTarget(patchId, targetId)) {
		extendLogPrefixWithTargetLabel(Label.fromClassId(targetId));
	}
	return targetId;
}
 
开发者ID:DexPatcher,项目名称:dexpatcher-tool,代码行数:25,代码来源:ClassSetPatcher.java

示例13: onSimpleAdd

import org.jf.dexlib2.iface.ClassDef; //导入依赖的package包/类
@Override
protected ClassDef onSimpleAdd(ClassDef patch, PatcherAnnotation annotation) {

	// Avoid creating a new object if not necessary.
	if (patch.getAnnotations() == annotation.getFilteredAnnotations()) {
		return patch;
	}

	return new BasicClassDef(
			patch.getType(),
			patch.getAccessFlags(),
			patch.getSuperclass(),
			patch.getInterfaces(),
			patch.getSourceFile(),
			annotation.getFilteredAnnotations(),
			patch.getStaticFields(),
			patch.getInstanceFields(),
			patch.getDirectMethods(),
			patch.getVirtualMethods());

}
 
开发者ID:DexPatcher,项目名称:dexpatcher-tool,代码行数:22,代码来源:ClassSetPatcher.java

示例14: renameClass

import org.jf.dexlib2.iface.ClassDef; //导入依赖的package包/类
private static ClassDef renameClass(ClassDef classDef, final String to) {

		final String from = classDef.getType();

		DexRewriter rewriter = new DexRewriter(new RewriterModule() {
			@Override
			public Rewriter<String> getTypeRewriter(Rewriters rewriters) {
				return new Rewriter<String>() {

					@Override
					public String rewrite(String value) {
						return from.equals(value) ? to : value;
					}

				};
			}
		});

		return rewriter.getClassDefRewriter().rewrite(classDef);

	}
 
开发者ID:DexPatcher,项目名称:dexpatcher-tool,代码行数:22,代码来源:ClassSetPatcher.java

示例15: test1

import org.jf.dexlib2.iface.ClassDef; //导入依赖的package包/类
public static void test1(String argv[]){
		try{
			DexBackedDexFile dexFile = DexFileFactory.loadDexFile(search_path, 16);
			for (ClassDef classDef: dexFile.getClasses()){
				if (classDef.getType().startsWith("Landroid") ||
						classDef.getType().startsWith("Ljava") ||
						classDef.getType().startsWith("Ldalvik")) {
					continue;
				}
				for (Method method: classDef.getMethods()){
//					if (method.getDefiningClass().equals("Lcom/cc/test/MainActivity;")
//							&& method.getName().equals("onCreate")){
					if (method.getImplementation() == null)
						continue;
					Grapher grapher = new Grapher(method.getImplementation());
					grapher.visitConstant();
					grapher.search();
//						grapher.printInfo();
//					}
				}
			}
			MethodConfig.printInfo();
		} catch (Exception e){
			e.printStackTrace();
		}
	}
 
开发者ID:CvvT,项目名称:DexTamper,代码行数:27,代码来源:Test.java


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