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


Java IClassHierarchy类代码示例

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


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

示例1: partialMatchForTrees

import com.ibm.wala.ipa.cha.IClassHierarchy; //导入依赖的package包/类
/**
 * Compute similarity scores for all provided {@link HashTree}. 
 * @param cha the {@link IClassHierarchy}
 * @param appProfile  the {@link AppProfile}
 * @param libProfile  the {@link LibProfile}
 * @param lvl  the level of matching to be applied (currently either Package or Class level)
 * @return  a {@link ProfileMatch} for the provided library profile
 * @throws NoSuchAlgorithmException
 */
public ProfileMatch partialMatchForTrees(final IClassHierarchy cha, final AppProfile appProfile, final LibProfile libProfile, final MatchLevel lvl) throws NoSuchAlgorithmException {
	ProfileMatch pMatch = new ProfileMatch(libProfile);
	logger.trace("Partial match of lib: " + libProfile);
	
	// check if library root package is present in app (for validation purposes)
	String rootPackage = libProfile.packageTree.getRootPackage();
	pMatch.libRootPackagePresent = rootPackage == null? false : appProfile.packageTree.containsPackage(rootPackage);
	logger.trace(Utils.INDENT + "Library root package " + rootPackage + " is " + (pMatch.libRootPackagePresent? "" : "not ") + " present in app!");
	 
	// calculate scores for each hash tree
	for (HashTree appHashTree: appProfile.hashTrees) {
		partialMatch(cha, pMatch, appHashTree, appProfile.packageTree, libProfile, lvl);
	}	

	if (logger.isTraceEnabled())
		pMatch.printResults(3);
	return pMatch;
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:28,代码来源:LibraryIdentifier.java

示例2: generateHashTrees

import com.ibm.wala.ipa.cha.IClassHierarchy; //导入依赖的package包/类
/**
	 * Generate hash trees for a certain {@link PackageTree} for all configurations
	 * @param cha  the {@link IClassHierarchy} instance
	 * @return  a List of {@link HashTree} for every configuration
	 */
	
// TODO: option to set different modes (normal, trace+pubonly, normal+pubonly)	
	public static List<HashTree> generateHashTrees(final IClassHierarchy cha) {
		final HashAlgorithm algorithm = HashAlgorithm.MD5;
		
		List<HashTree> hTrees = new ArrayList<HashTree>();
		try {
			boolean filterDups = false;
			boolean filterInnerClasses = false;
			
			HashTree hashTree = new HashTree(filterDups, filterInnerClasses, algorithm);

			if (TplCLI.CliOptions.genVerboseProfiles) {
				hashTree.setBuildVerboseness(HashTree.HTREE_BUILD_VERBOSENESS.TRACE);
				hashTree.setPublicOnlyFilter();
			}
			hashTree.generate(cha);
			hTrees.add(hashTree);
		} catch (NoSuchAlgorithmException e) {
			logger.error(Utils.stacktrace2Str(e));
		}	
		
		return hTrees;
	}
 
开发者ID:reddr,项目名称:LibScout,代码行数:30,代码来源:Profile.java

示例3: create

import com.ibm.wala.ipa.cha.IClassHierarchy; //导入依赖的package包/类
public static AppProfile create(IClassHierarchy cha) {
	long startTime = System.currentTimeMillis();
	
	// generate app package tree
	PackageTree ptree = Profile.generatePackageTree(cha);
	logger.info("- generated app package tree (in " + Utils.millisecondsToFormattedTime(System.currentTimeMillis() - startTime) + ")");
	logger.info("");
	
	// generate app hash trees
	startTime = System.currentTimeMillis();
	List<HashTree> hashTrees = Profile.generateHashTrees(cha);
	logger.info("- generated app hash trees (in " + Utils.millisecondsToFormattedTime(System.currentTimeMillis() - startTime) + ")");
	logger.info("");
	
	return new AppProfile(ptree, hashTrees);
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:17,代码来源:AppProfile.java

示例4: getIMethod

import com.ibm.wala.ipa.cha.IClassHierarchy; //导入依赖的package包/类
public static IMethod getIMethod(IClassHierarchy cha, String signature) {  // TODO: throw exceptions
	String clazzName = Utils.getFullClassName(signature);
	String selector = signature.substring(clazzName.length()+1); 

	try {
		IClass clazz = WalaUtils.lookupClass(cha, clazzName);
		for (IMethod m: clazz.getAllMethods()) { // DeclaredMethods()) -> only impl./overriden methods
			if (m.getSelector().toString().equals(selector)) {
				return m;
			}
		}
	} catch (ClassNotFoundException e) {
		logger.debug("Classname " + clazzName + " could not be looked up!");
	}
	return null;  // TODO: throw exception
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:17,代码来源:WalaUtils.java

示例5: getLayoutClass

import com.ibm.wala.ipa.cha.IClassHierarchy; //导入依赖的package包/类
private IClass getLayoutClass(IClassHierarchy cha, String clazzName) {
	// This is due to the fault-tolerant xml parser
	if (clazzName.equals("view")) clazzName = "View";

	IClass iclazz = null;
	if (iclazz == null)
		iclazz = cha.lookupClass(TypeReference.findOrCreate(ClassLoaderReference.Application, Utils.convertToBrokenDexBytecodeNotation(clazzName)));
	if (iclazz == null && !packageName.isEmpty())
		iclazz = cha.lookupClass(TypeReference.findOrCreate(ClassLoaderReference.Application, Utils.convertToBrokenDexBytecodeNotation(packageName + "." + clazzName)));
	if (iclazz == null)
		iclazz = cha.lookupClass(TypeReference.findOrCreate(ClassLoaderReference.Application, Utils.convertToBrokenDexBytecodeNotation("android.widget." + clazzName)));
	if (iclazz == null)	
		iclazz = cha.lookupClass(TypeReference.findOrCreate(ClassLoaderReference.Application, Utils.convertToBrokenDexBytecodeNotation("android.webkit." + clazzName)));
	if (iclazz == null)
		iclazz = cha.lookupClass(TypeReference.findOrCreate(ClassLoaderReference.Application, Utils.convertToBrokenDexBytecodeNotation("android.view." + clazzName)));
	
	// PreferenceScreen, PreferenceCategory, (i)shape, item, selector, scale, corners, solid .. tags are no classes and thus there will be no corresponding layout class
	if (iclazz == null)	
		logger.trace(Utils.INDENT + "Could not find layout class " + clazzName);

	return iclazz;
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:23,代码来源:LayoutFileParser.java

示例6: makeCG

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

示例7: makeAnalysisOptions

import com.ibm.wala.ipa.cha.IClassHierarchy; //导入依赖的package包/类
/**
 * Note that the resulting `AnalysisOptions` object does not have any entrypoints.
 * 
 * @param cha
 * @param scope
 * @return
 */
public static AnalysisOptions makeAnalysisOptions(IClassHierarchy cha)
{
    AnalysisScope scope = cha.getScope();
    AnalysisOptions options = new AnalysisOptions(scope, null);

    ClassLoader classLoader = WalaUtil.class.getClassLoader();
    InputStream nativesSpec = classLoader.getResourceAsStream(NATIVE_SPEC_RESOURCE_NAME);
    XMLMethodSummaryReader nativeSpecSummary = new XMLMethodSummaryReader(nativesSpec, scope);

    // Add default selectors then custom ones. The defaults will serve as the parents of the
    // custom children. The children delegate to their parents when they do not definitively
    // target a class/method.
    Util.addDefaultSelectors(options, cha);
    setToSynthesizeNativeMethods(cha, options, nativeSpecSummary);
    setToSynthesizeNativeClasses(cha, options, nativeSpecSummary);

    return options;
}
 
开发者ID:paninij,项目名称:paninij,代码行数:26,代码来源:WalaUtil.java

示例8: isInitialNodeByCallSite

import com.ibm.wala.ipa.cha.IClassHierarchy; //导入依赖的package包/类
/**
 * @return True iff the given call site indicates that the enclosing call graph node is
 * considered an "initial" node.
 */
private static boolean isInitialNodeByCallSite(CGNode node, CallSiteReference callSite)
{
    IClassHierarchy cha = node.getClassHierarchy();
    MethodReference calleeMethod = callSite.getDeclaredTarget();
    IClass calleeClass = cha.lookupClass(calleeMethod.getDeclaringClass());

    if (calleeClass == null || isCapsuleInterface(calleeClass) == false) {
        return false;
    }
    if (calleeMethod.getNumberOfParameters() == 0) {
        return false;
    }
    
    return true;
}
 
开发者ID:paninij,项目名称:paninij,代码行数:20,代码来源:SoterUtil.java

示例9: CallGraphLiveAnalysis

import com.ibm.wala.ipa.cha.IClassHierarchy; //导入依赖的package包/类
public CallGraphLiveAnalysis(CapsuleCore core, CallGraphAnalysis cga,
                             TransferAnalysis ta, TransferLiveAnalysis tla,
                             IClassHierarchy cha)
{
    this.core = core;
    this.cga = cga;
    this.ta = ta;
    this.tla = tla;
    this.cha = cha;
    
    transferFunctionProvider = new TransferFunctionProvider();
    liveVariables = new HashMap<CGNode, Map<TransferSite, BitVector>>();
    globalLatticeValues = MutableMapping.make();
    
    hasBeenPerformed = false;
}
 
开发者ID:paninij,项目名称:paninij,代码行数:17,代码来源:CallGraphLiveAnalysis.java

示例10: SoterAnalysis

import com.ibm.wala.ipa.cha.IClassHierarchy; //导入依赖的package包/类
public SoterAnalysis(CapsuleCore core, CallGraphAnalysis cga, TransferAnalysis ta,
                     TransferLiveAnalysis tla, CallGraphLiveAnalysis cgla, IClassHierarchy cha)
{
    this.core = core;
    this.cga = cga;
    this.ta = ta;
    this.tla = tla;
    this.cgla = cgla;
    this.cha = cha;

    intSetFactory = new MutableSparseIntSetFactory();

    transferSiteResultsMap = new HashMap<TransferSite, TransferSiteResults>();
    unsafeTransferSitesMap = new HashMap<IMethod, IdentitySet<TransferSite>>();

    jsonCreator = new JsonResultsCreator(this);
}
 
开发者ID:paninij,项目名称:paninij,代码行数:18,代码来源:SoterAnalysis.java

示例11: createECJJavaEngine

import com.ibm.wala.ipa.cha.IClassHierarchy; //导入依赖的package包/类
public static JavaSourceAnalysisEngine
createECJJavaEngine(Collection<String> sources, List<String> libs, final String [] entryPoints)  {
    JavaSourceAnalysisEngine engine=null;
    if(null == entryPoints) {
        engine = new ECJJavaSourceAnalysisEngine();
    } else {
        engine = new ECJJavaSourceAnalysisEngine() {
            @Override
            protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
                return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE,cha, entryPoints);
            }
        };
    }
    engine.setExclusionsFile(REGRESSION_EXCLUSIONS);
    populateScope(engine, sources, libs);
    return engine;
}
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:18,代码来源:PlugInUtil.java

示例12: makeCG

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

示例13: makeCG

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

示例14: generatePackageTree

import com.ibm.wala.ipa.cha.IClassHierarchy; //导入依赖的package包/类
public static PackageTree generatePackageTree(IClassHierarchy cha) {
	logger.info("= PackageTree =");
	PackageTree tree = PackageTree.make(cha, true);
	tree.print(true);
	
	logger.debug("");
	logger.debug("Package names (included classes):");
	Map<String,Integer> pTree = tree.getPackages();
	for (String pkg: pTree.keySet())
		logger.debug(Utils.INDENT + pkg + " (" + pTree.get(pkg) + ")");

	logger.info("");
	
	return tree;
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:16,代码来源:Profile.java

示例15: lookupClass

import com.ibm.wala.ipa.cha.IClassHierarchy; //导入依赖的package包/类
/**
 * Looks up an IClass for a given class name
 * @param cha  a {@link IClassHierarchy}
 * @param clazzName  in java notation, e.g. "de.infsec.MyActivity"
 * @return a {@link IClass} object
 * @throws ClassNotFoundException
 */
public static IClass lookupClass(IClassHierarchy cha, String clazzName) throws ClassNotFoundException {
	if (clazzName == null)
		throw new ClassNotFoundException(Utils.INDENT + "class name is NULL");
	
	String convertedClass = Utils.convertToBrokenDexBytecodeNotation(clazzName);
	IClass iclazz = cha.lookupClass(TypeReference.findOrCreate(ClassLoaderReference.Application, convertedClass));
	
	if (iclazz == null)
		throw new ClassNotFoundException(Utils.INDENT + "[lookupClass] Could'nt lookup IClass for " + clazzName);
	
	return iclazz;
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:20,代码来源:WalaUtils.java


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