本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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;
}