本文整理汇总了Java中com.ibm.wala.ipa.cha.IClassHierarchy类的典型用法代码示例。如果您正苦于以下问题:Java IClassHierarchy类的具体用法?Java IClassHierarchy怎么用?Java IClassHierarchy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IClassHierarchy类属于com.ibm.wala.ipa.cha包,在下文中一共展示了IClassHierarchy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: make
import com.ibm.wala.ipa.cha.IClassHierarchy; //导入依赖的package包/类
public static PackageTree make(IClassHierarchy cha, boolean appClassesOnly, Set<String> filteredPackages) {
PackageTree tree = new PackageTree();
for (Iterator<IClass> it = cha.iterator(); it.hasNext(); ) {
IClass clazz = it.next();
if (!appClassesOnly || (appClassesOnly && WalaUtils.isAppClass(clazz))) {
if (filteredPackages == null || !filteredPackages.contains(PackageUtils.getPackageName(clazz)))
tree.update(clazz);
}
}
return tree;
}
开发者ID:reddr,项目名称:LibScout,代码行数:13,代码来源:PackageTree.java
示例17: updateTreeClazzCount
import com.ibm.wala.ipa.cha.IClassHierarchy; //导入依赖的package包/类
public void updateTreeClazzCount(IClassHierarchy cha) {
Set<String> packages = this.getAllPackages();
for (Iterator<IClass> it = cha.iterator(); it.hasNext(); ) {
IClass clazz = it.next();
if (WalaUtils.isAppClass(clazz)) {
if (packages.contains(PackageUtils.getPackageName(clazz))) {
updateClazzCount(clazz);
}
}
}
}
开发者ID:reddr,项目名称:LibScout,代码行数:14,代码来源:PackageTree.java
示例18: main
import com.ibm.wala.ipa.cha.IClassHierarchy; //导入依赖的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
示例19: makePublicEntrypoints
import com.ibm.wala.ipa.cha.IClassHierarchy; //导入依赖的package包/类
private static Iterable<Entrypoint> makePublicEntrypoints(AnalysisScope scope, IClassHierarchy cha, String entryClass) {
Collection<Entrypoint> result = new ArrayList<Entrypoint>();
IClass klass = cha.lookupClass(TypeReference.findOrCreate(ClassLoaderReference.Application,
StringStuff.deployment2CanonicalTypeString(entryClass)));
for (IMethod m : klass.getDeclaredMethods()) {
if (m.isPublic()) {
result.add(new DefaultEntrypoint(m, cha));
}
}
return result;
}
开发者ID:wala,项目名称:WALA-start,代码行数:12,代码来源:ScopeFileCallGraph.java
示例20: removeErrorModules
import com.ibm.wala.ipa.cha.IClassHierarchy; //导入依赖的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
注:本文中的com.ibm.wala.ipa.cha.IClassHierarchy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论