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


Java ClassHierarchyException类代码示例

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


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

示例1: createClassHierarchy

import com.ibm.wala.ipa.cha.ClassHierarchyException; //导入依赖的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: main

import com.ibm.wala.ipa.cha.ClassHierarchyException; //导入依赖的package包/类
/**
 * This main program shows one example use of thread escape analysis: producing a set of fields to be monitored for a
 * dynamic race detector. The idea is that any field might have a race with two exceptions: final fields do not have
 * races since there are no writes to them, and volatile fields have atomic read and write semantics provided by the
 * VM. Hence, this piece of code produces a list of all other fields.
 * @throws CancelException
 * @throws IllegalArgumentException
 */
public static void main(String[] args) throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
  String mainClassName = args[0];

  Set<JarFile> jars = HashSetFactory.make();
  for (int i = 1; i < args.length; i++) {
    jars.add(new JarFile(args[i]));
  }

  Set<IClass> escapingTypes = (new SimpleThreadEscapeAnalysis(jars, mainClassName)).gatherThreadEscapingClasses();

  for (Iterator<IClass> types = escapingTypes.iterator(); types.hasNext();) {
    IClass cls = types.next();
    if (!cls.isArrayClass()) {
      for (Iterator<IField> fs = cls.getAllFields().iterator(); fs.hasNext();) {
        IField f = fs.next();
        if (!f.isVolatile() && !f.isFinal()) {
          System.err.println(f.getReference());
        }
      }
    }
  }
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:31,代码来源:SimpleThreadEscapeAnalysis.java

示例3: makeCG

import com.ibm.wala.ipa.cha.ClassHierarchyException; //导入依赖的package包/类
protected static JSCFABuilder makeCG(JavaScriptLoaderFactory loaders, AnalysisScope scope, CGBuilderType builderType, IRFactory<IMethod> irFactory) throws IOException, WalaException {
  try {
    IClassHierarchy cha = makeHierarchy(scope, loaders);
    com.ibm.wala.cast.js.util.Util.checkForFrontEndErrors(cha);
    Iterable<Entrypoint> roots = makeScriptRoots(cha);
    JSAnalysisOptions options = makeOptions(scope, cha, roots);
    options.setHandleCallApply(builderType.handleCallApply());
    AnalysisCache cache = makeCache(irFactory);
    JSCFABuilder builder = new JSZeroOrOneXCFABuilder(cha, options, cache, null, null, ZeroXInstanceKeys.ALLOCATIONS,
        builderType.useOneCFA());
    if(builderType.extractCorrelatedPairs())
      builder.setContextSelector(new PropertyNameContextSelector(builder.getAnalysisCache(), 2, builder.getContextSelector()));

    return builder;
  } catch (ClassHierarchyException e) {
    return null;
  }
}
 
开发者ID:ylimit,项目名称:HybridFlow,代码行数:19,代码来源:JSCallGraphBuilderUtil.java

示例4: makeCG

import com.ibm.wala.ipa.cha.ClassHierarchyException; //导入依赖的package包/类
protected static JSCFABuilder makeCG(JavaScriptLoaderFactory loaders,
                                     AnalysisScope scope, CGBuilderType builderType,
                                     IRFactory<IMethod> irFactory) throws IOException, WalaException {
    try {
        IClassHierarchy cha = makeHierarchy(scope, loaders);
        com.ibm.wala.cast.util.Util.checkForFrontEndErrors(cha);
        Iterable<Entrypoint> roots = makeScriptRoots(cha);
        JSAnalysisOptions options = makeOptions(scope, cha, roots);
        options.setHandleCallApply(builderType.handleCallApply());
        IAnalysisCacheView cache = makeCache(irFactory);
        JSCFABuilder builder = new JSZeroOrOneXCFABuilder(cha, options,
                cache, null, null, ZeroXInstanceKeys.ALLOCATIONS,
                builderType.useOneCFA());
        
        if (builderType.extractCorrelatedPairs())
            builder.setContextSelector(new PropertyNameContextSelector(
                                           builder.getAnalysisCache(), 2, builder
                                           .getContextSelector()));

        return builder;
    } catch (ClassHierarchyException e) {
        // Assert.assertTrue("internal error building class hierarchy",
        // false);
        return null;
    }
}
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:27,代码来源:ImprovedJSCallGraphBuilderUtil.java

示例5: makeCG

import com.ibm.wala.ipa.cha.ClassHierarchyException; //导入依赖的package包/类
protected static JSCFABuilder makeCG(JavaScriptLoaderFactory loaders, AnalysisScope scope, CGBuilderType builderType, IRFactory<IMethod> irFactory) throws IOException, WalaException {
  try {
    IClassHierarchy cha = makeHierarchy(scope, loaders);
    com.ibm.wala.cast.js.util.Util.checkForFrontEndErrors(cha);
    Iterable<Entrypoint> roots = makeScriptRoots(cha);
    JSAnalysisOptions options = makeOptions(scope, cha, roots);
    options.setHandleCallApply(builderType.handleCallApply());
    AnalysisCache cache = makeCache(irFactory);
    JSCFABuilder builder = new JSZeroOrOneXCFABuilder(cha, options, cache, null, null, ZeroXInstanceKeys.ALLOCATIONS,
        builderType.useOneCFA());
    if(builderType.extractCorrelatedPairs())
      builder.setContextSelector(new PropertyNameContextSelector(builder.getAnalysisCache(), 2, builder.getContextSelector()));

    return builder;
  } catch (ClassHierarchyException e) {
    Assert.assertTrue("internal error building class hierarchy", false);
    return null;
  }
}
 
开发者ID:blackoutjack,项目名称:jamweaver,代码行数:20,代码来源:JSCallGraphBuilderUtil.java

示例6: TargetApplication

import com.ibm.wala.ipa.cha.ClassHierarchyException; //导入依赖的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

示例7: main

import com.ibm.wala.ipa.cha.ClassHierarchyException; //导入依赖的package包/类
/**
   * Usage: ScopeFileCallGraph -scopeFile file_path [-entryClass class_name |
   * -mainClass class_name]
   * 
   * If given -mainClass, uses main() method of class_name as entrypoint. If
   * given -entryClass, uses all public methods of class_name.
   * 
   * @throws IOException
   * @throws ClassHierarchyException
   * @throws CallGraphBuilderCancelException
   * @throws IllegalArgumentException
   */
  public static void main(String[] args) throws IOException, ClassHierarchyException, IllegalArgumentException,
      CallGraphBuilderCancelException {
    long start = System.currentTimeMillis();
    Properties p = CommandLine.parse(args);
    String scopeFile = p.getProperty("scopeFile");
    String entryClass = p.getProperty("entryClass");
    String mainClass = p.getProperty("mainClass");
    if (mainClass != null && entryClass != null) {
      throw new IllegalArgumentException("only specify one of mainClass or entryClass");
    }
    AnalysisScope scope = AnalysisScopeReader.readJavaScope(scopeFile, null, ScopeFileCallGraph.class.getClassLoader());
    // set exclusions.  we use these exclusions as standard for handling JDK 8
    ExampleUtil.addDefaultExclusions(scope);
    IClassHierarchy cha = ClassHierarchyFactory.make(scope);
    System.out.println(cha.getNumberOfClasses() + " classes");
    System.out.println(Warnings.asString());
    Warnings.clear();
    AnalysisOptions options = new AnalysisOptions();
    Iterable<Entrypoint> entrypoints = entryClass != null ? makePublicEntrypoints(scope, cha, entryClass) : Util.makeMainEntrypoints(scope, cha, mainClass);
    options.setEntrypoints(entrypoints);
    // you can dial down reflection handling if you like
//    options.setReflectionOptions(ReflectionOptions.NONE);
    AnalysisCache cache = new AnalysisCacheImpl();
    // other builders can be constructed with different Util methods
    CallGraphBuilder builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope);
//    CallGraphBuilder builder = Util.makeNCFABuilder(2, options, cache, cha, scope);
//    CallGraphBuilder builder = Util.makeVanillaNCFABuilder(2, options, cache, cha, scope);
    System.out.println("building call graph...");
    CallGraph cg = builder.makeCallGraph(options, null);
    long end = System.currentTimeMillis();
    System.out.println("done");
    System.out.println("took " + (end-start) + "ms");
    System.out.println(CallGraphStats.getStats(cg));
  }
 
开发者ID:wala,项目名称:WALA-start,代码行数:47,代码来源:ScopeFileCallGraph.java

示例8: removeErrorModules

import com.ibm.wala.ipa.cha.ClassHierarchyException; //导入依赖的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

示例9: loadClassHierachie

import com.ibm.wala.ipa.cha.ClassHierarchyException; //导入依赖的package包/类
@BeforeClass
public static void loadClassHierachie() throws IOException, ClassHierarchyException {
	if (targetApplication == null) {
		targetApplication = TestUtilities.loadTestJar();
	}

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

示例10: extractFingerPrints

import com.ibm.wala.ipa.cha.ClassHierarchyException; //导入依赖的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

示例11: main

import com.ibm.wala.ipa.cha.ClassHierarchyException; //导入依赖的package包/类
/**
	   * Usage: CSReachingDefsDriver -scopeFile file_path -mainClass class_name
	   * 
	   * Uses main() method of class_name as entrypoint.
	   * 
	   * @throws IOException
	   * @throws ClassHierarchyException
	   * @throws CallGraphBuilderCancelException
	   * @throws IllegalArgumentException
	   */
	  public static void main(String[] args) throws IOException, ClassHierarchyException, IllegalArgumentException, CallGraphBuilderCancelException {
	    long start = System.currentTimeMillis();		
	    Properties p = CommandLine.parse(args);
	    String scopeFile = p.getProperty("scopeFile");
	    if (scopeFile == null) {
	    	throw new IllegalArgumentException("must specify scope file");
	    }
	    String mainClass = p.getProperty("mainClass");
	    if (mainClass == null) {
	      throw new IllegalArgumentException("must specify main class");
	    }
	    AnalysisScope scope = AnalysisScopeReader.readJavaScope(scopeFile, null, CSReachingDefsDriver.class.getClassLoader());
	    ExampleUtil.addDefaultExclusions(scope);
	    IClassHierarchy cha = ClassHierarchyFactory.make(scope);
	    System.out.println(cha.getNumberOfClasses() + " classes");
	    System.out.println(Warnings.asString());
	    Warnings.clear();
	    AnalysisOptions options = new AnalysisOptions();
	    Iterable<Entrypoint> entrypoints = Util.makeMainEntrypoints(scope, cha, mainClass);
	    options.setEntrypoints(entrypoints);
	    // you can dial down reflection handling if you like
	    options.setReflectionOptions(ReflectionOptions.NONE);
	    AnalysisCache cache = new AnalysisCacheImpl();
	    // other builders can be constructed with different Util methods
	    CallGraphBuilder builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope);
//	    CallGraphBuilder builder = Util.makeNCFABuilder(2, options, cache, cha, scope);
//	    CallGraphBuilder builder = Util.makeVanillaNCFABuilder(2, options, cache, cha, scope);
	    System.out.println("building call graph...");
	    CallGraph cg = builder.makeCallGraph(options, null);
//	    System.out.println(cg);
	    long end = System.currentTimeMillis();
	    System.out.println("done");
	    System.out.println("took " + (end-start) + "ms");
	    System.out.println(CallGraphStats.getStats(cg));
	    
	    ContextSensitiveReachingDefs reachingDefs = new ContextSensitiveReachingDefs(cg, cache);
	    TabulationResult<BasicBlockInContext<IExplodedBasicBlock>, CGNode, Pair<CGNode, Integer>> result = reachingDefs.analyze();
	    ISupergraph<BasicBlockInContext<IExplodedBasicBlock>, CGNode> supergraph = reachingDefs.getSupergraph();

	    // TODO print out some analysis results
	}
 
开发者ID:wala,项目名称:WALA-start,代码行数:52,代码来源:CSReachingDefsDriver.java


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