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

Java ClassHierarchy类代码示例

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

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



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

示例1: createClassHierarchy

import com.ibm.wala.ipa.cha.ClassHierarchy; //导入依赖的package包/类
private void createClassHierarchy() throws IOException, ClassHierarchyException {
	long s = System.currentTimeMillis();

	// check if we have a multi-dex file
	stats.isMultiDex = ApkUtils.isMultiDexApk(stats.appFile);
	if (stats.isMultiDex)
		logger.info("Multi-dex apk detected - Code is merged to single class hierarchy!");

	// create analysis scope and generate class hierarchy
	// we do not need additional libraries like support libraries,
	// as they are statically linked in the app code.
	final AnalysisScope scope = AndroidAnalysisScope.setUpAndroidAnalysisScope(new File(stats.appFile.getAbsolutePath()).toURI(), null /* no exclusions */, null /* we always pass an android lib */, CliOptions.pathToAndroidJar.toURI());

	cha = ClassHierarchy.make(scope);
	logger.info("generated class hierarchy (in " + Utils.millisecondsToFormattedTime(System.currentTimeMillis() - s) + ")");
	LibraryProfiler.getChaStats(cha);
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:18,代码来源:LibraryIdentifier.java


示例2: TargetApplication

import com.ibm.wala.ipa.cha.ClassHierarchy; //导入依赖的package包/类
public TargetApplication(String jarName, String exclusionFileName)
		throws IOException, ClassHierarchyException {
	LOG.info("creating analysis scope for {}", jarName);

	File exclusionFile = null;
	if (exclusionFileName != null) {
		LOG.info("using exclusion file {}", exclusionFileName);

		exclusionFile = new File(exclusionFileName);

	}
	scope = AnalysisScopeFactory.createJavaAnalysisScope(jarName,
			exclusionFile);

	LOG.info("building class hierarchy...", jarName);
	classHierarchy = ClassHierarchy.make(scope);

	cache = new AnalysisCache();
	options = new AnalysisOptions();

}
 
开发者ID:wondee,项目名称:faststring,代码行数:22,代码来源:TargetApplication.java


示例3: run

import com.ibm.wala.ipa.cha.ClassHierarchy; //导入依赖的package包/类
public static Process run(String[] args) throws IOException {
  try {
    validateCommandLine(args);
    String classpath = args[CLASSPATH_INDEX];
    AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(classpath, null);
    ExampleUtil.addDefaultExclusions(scope);

    // invoke WALA to build a class hierarchy
    ClassHierarchy cha = ClassHierarchyFactory.make(scope);

    Graph<IClass> g = typeHierarchy2Graph(cha);

    g = pruneForAppLoader(g);
    //String dotFile = "/tmp" + File.separatorChar + DOT_FILE;
    String dotFile = File.createTempFile("out", ".dt").getAbsolutePath();
    String pdfFile = File.createTempFile("out", ".pdf").getAbsolutePath();
    String dotExe = "dot";
    String gvExe = "open";
    DotUtil.dotify(g, null, dotFile, pdfFile, dotExe);
    return PDFViewUtil.launchPDFView(pdfFile, gvExe);

  } catch (WalaException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    return null;
  }
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:28,代码来源:PDFTypeHierarchy.java


示例4: removeErrorModules

import com.ibm.wala.ipa.cha.ClassHierarchy; //导入依赖的package包/类
private SourceModule[] removeErrorModules(SourceModule[] scriptsArray, JavaScriptLoaderFactory loaders)
        throws IOException, ClassHierarchyException {
    AnalysisScope scope = CAstCallGraphUtil.makeScope(scriptsArray, loaders, JavaScriptLoader.JS);
    IClassHierarchy cha = ClassHierarchy.make(scope, loaders, JavaScriptLoader.JS);
    Set<ModuleEntry> errorModules = new HashSet<>();
    for (IClassLoader loader : cha.getLoaders()) {
        if(loader instanceof CAstAbstractLoader) {
            Iterator errors = ((CAstAbstractLoader)loader).getModulesWithParseErrors();

            while(errors.hasNext()) {
                ModuleEntry errorModule = (ModuleEntry)errors.next();
                errorModules.add(errorModule);
            }

            ((CAstAbstractLoader)loader).clearMessages();
        }
    }

    Set<SourceModule> newSourceModules = new HashSet<>();
    for (SourceModule sourceModule : scriptsArray) {
        boolean isErrorModule = false;
        Iterator<? extends ModuleEntry> moduleEntries = sourceModule.getEntries();
        while (moduleEntries.hasNext()) {
            ModuleEntry moduleEntry = moduleEntries.next();
            if (errorModules.contains(moduleEntry)) {
                isErrorModule = true;
                break;
            }
        }
        if (isErrorModule) {
            continue;
        }
        newSourceModules.add(sourceModule);
    }
    return newSourceModules.toArray(new SourceModule[newSourceModules.size()]);
}
 
开发者ID:ylimit,项目名称:HybridFlow,代码行数:37,代码来源:WebManager.java


示例5: printToPDF

import com.ibm.wala.ipa.cha.ClassHierarchy; //导入依赖的package包/类
public static void printToPDF(String pathname, ClassHierarchy cha, IR ir) throws WalaException, IOException {

		Properties wp = loadProperties();

		File file = new File(TARGET_IRS);

		if (!file.exists()) {
			file.mkdirs();
		}

		wp.put(WalaProperties.OUTPUT_DIR, TARGET_IRS);

		String pdfFile = wp.getProperty(WalaProperties.OUTPUT_DIR) +
						 File.separatorChar +
						 TestUtilities.createFileName(ir.getMethod().getDeclaringClass().getName().toString(),
								 ir.getMethod().getName().toString()) +
								 ".pdf";

		String dotFile = wp.getProperty(WalaProperties.OUTPUT_DIR)
				+ File.separatorChar + "ir.dt";
		if (new File(pdfFile).exists()) {
			LOG.info("skipping {}", pdfFile);
		} else {
			Graph<ISSABasicBlock> g = ir.getControlFlowGraph();

			NodeDecorator<ISSABasicBlock> labels = PDFViewUtil.makeIRDecorator(ir);
			g = CFGSanitizer.sanitize(ir, cha);

			DotUtil.dotify(g, labels, dotFile, pdfFile, (String)wp.get("dot"));
		}
	}
 
开发者ID:wondee,项目名称:faststring,代码行数:32,代码来源:PrintTestIRs.java


示例6: extractFingerPrints

import com.ibm.wala.ipa.cha.ClassHierarchy; //导入依赖的package包/类
public void extractFingerPrints() throws IOException, ClassHierarchyException, ClassNotFoundException {
	long starttime = System.currentTimeMillis();
	
	logger.info("Process library: " + libraryFile.getName());
	logger.info("Library description:");
	for (String desc: libDesc.getDescription())
		logger.info(desc);
	
	// create analysis scope and generate class hierarchy
	final AnalysisScope scope = AnalysisScope.createJavaAnalysisScope();
	
	JarFile jf = libraryFile.getName().endsWith(".aar")? new AarFile(libraryFile).getJarFile() : new JarFile(libraryFile); 
	scope.addToScope(ClassLoaderReference.Application, jf);
	scope.addToScope(ClassLoaderReference.Primordial, new JarFile(CliOptions.pathToAndroidJar));

	IClassHierarchy cha = ClassHierarchy.make(scope);
	getChaStats(cha);
	
	// cleanup tmp files if library input was an .aar file
	if (libraryFile.getName().endsWith(".aar")) {
		File tmpJar = new File(jf.getName());
		tmpJar.delete();
		logger.debug(Utils.indent() + "tmp jar-file deleted at " + tmpJar.getName());
	}
	
	PackageTree pTree = Profile.generatePackageTree(cha);
	if (pTree.getRootPackage() == null) {
		logger.warn(Utils.INDENT + "Library contains multiple root packages");
	}

	List<HashTree> hTrees = Profile.generateHashTrees(cha);

	// if hash tree is empty do not dump a profile
	if (hTrees.isEmpty() || hTrees.get(0).getNumberOfClasses() == 0) {
		logger.error("Empty Hash Tree generated - SKIP");
		return;
	}		
		
	// serialize lib profiles to disk (<profilesDir>/<lib-category>/libName_libVersion.lib)
	logger.info("");
	File targetDir = new File(CliOptions.profilesDir + File.separator + libDesc.category.toString());
	logger.info("Serialize library fingerprint to disk (dir: " + targetDir + ")");
	String proFileName = libDesc.name.replaceAll(" ", "-") + "_" + libDesc.version + "." + FILE_EXT_LIB_PROFILE;
	LibProfile lp = new LibProfile(libDesc, pTree, hTrees);
	
	Utils.object2Disk(new File(targetDir + File.separator + proFileName), lp);
	
	logger.info("");
	logger.info("Processing time: " + Utils.millisecondsToFormattedTime(System.currentTimeMillis() - starttime));
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:51,代码来源:LibraryProfiler.java


示例7: getCallGraph

import com.ibm.wala.ipa.cha.ClassHierarchy; //导入依赖的package包/类
/**
 * Gets callgraph for given parameters (binary analysis only)
 * @param exclusionFilePath
 * @param classPath
 * @param entryClass
 * @param entryMethod
 * @return
 */
public static CallGraph getCallGraph(String exclusionFilePath, String classPath, String entryClass, String entryMethod) {
    AnalysisScope scope = null;
    ClassHierarchy cha = null;
    HashSet<Entrypoint> entryPoints = null;
    try {
        File exclusionFile = new File(exclusionFilePath);
        scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(classPath, exclusionFile); // works with class and jar files
        cha = ClassHierarchyFactory.make(scope);

        ClassLoaderReference clr = scope.getApplicationLoader();
        entryPoints = HashSetFactory.make();
        for(IClass class1 : cha) {
            if(class1.getClassLoader().getReference().equals(clr)) {
                Collection<IMethod> allMethods = class1.getDeclaredMethods();
                for(IMethod m : allMethods) {
                    if(m.isPrivate()) {
                        continue;
                    }
                    TypeName tn = m.getDeclaringClass().getName();//MainApplication
                    if(tn.toString().contains("/" + entryClass) && m.getName().toString().contains(entryMethod)) { // TODO: too weak
                        entryPoints.add(new DefaultEntrypoint(m, cha));
                    }
                }
            }
        }
        //	    Iterable<Entrypoint> result1 = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha); // uses the static main methods as entry methods
        if(entryPoints.size() == 0) {
            log.error("Could not find specified entry point for analysis.\n" +
                      " path: " + classPath + "\n" +
                      " class: " + entryClass + "\n" +
                      " method: " + entryMethod);
            System.exit(1);
        }
        AnalysisOptions options = new AnalysisOptions(scope, entryPoints);

        //		CallGraphBuilder builder = com.ibm.wala.ipa.callgraph.impl.Util.makeRTABuilder(options, new AnalysisCacheImpl(), cha, scope); // Rapid Type Analysis
        SSAPropagationCallGraphBuilder builder = com.ibm.wala.ipa.callgraph.impl.Util.makeZeroCFABuilder(options, new AnalysisCacheImpl(), cha, scope); // 0-CFA = context-insensitive, class-based heap
        //		CallGraphBuilder builder = com.ibm.wala.ipa.callgraph.impl.Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); // 0-1-CFA = context-insensitive, allocation-site-based heap
        //		CallGraphBuilder builder = com.ibm.wala.ipa.callgraph.impl.Util.makeZeroOneContainerCFABuilder(options, new AnalysisCacheImpl(), cha, scope); // 0-1-Container-CFA = object-sensitive container

        return builder.makeCallGraph(options);
    } catch (Exception e) {
        log.error("Error while building the call graph");
        e.printStackTrace();
        System.exit(1);
        return null;
    }
}
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:57,代码来源:AnalysisUtil.java


示例8: getClassHierachy

import com.ibm.wala.ipa.cha.ClassHierarchy; //导入依赖的package包/类
public ClassHierarchy getClassHierachy() {
	return classHierarchy;
}
 
开发者ID:wondee,项目名称:faststring,代码行数:4,代码来源:TargetApplication.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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