本文整理汇总了Java中com.ibm.wala.types.ClassLoaderReference类的典型用法代码示例。如果您正苦于以下问题:Java ClassLoaderReference类的具体用法?Java ClassLoaderReference怎么用?Java ClassLoaderReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClassLoaderReference类属于com.ibm.wala.types包,在下文中一共展示了ClassLoaderReference类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getLayoutClass
import com.ibm.wala.types.ClassLoaderReference; //导入依赖的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
示例2: lookupClass
import com.ibm.wala.types.ClassLoaderReference; //导入依赖的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
示例3: makePublicEntrypoints
import com.ibm.wala.types.ClassLoaderReference; //导入依赖的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
示例4: pruneForAppLoader
import com.ibm.wala.types.ClassLoaderReference; //导入依赖的package包/类
/**
* Restrict g to nodes from the Application loader
*/
public static Graph<IClass> pruneForAppLoader(Graph<IClass> g) throws WalaException {
Predicate<IClass> f = new Predicate<IClass>() {
@Override public boolean test(IClass c) {
return (c.getClassLoader().getReference().equals(ClassLoaderReference.Application));
}
};
return pruneGraph(g, f);
}
开发者ID:wala,项目名称:WALA-start,代码行数:12,代码来源:PDFTypeHierarchy.java
示例5: loadCoreClass
import com.ibm.wala.types.ClassLoaderReference; //导入依赖的package包/类
/**
* @param cha
* @param coreName The name of the core to be analyzed. Should be something of the form
* `-Lorg/paninij/soter/FooCore`.
*/
public static IClass loadCoreClass(String coreName, IClassHierarchy cha)
{
AnalysisScope scope = cha.getScope();
ClassLoaderReference appLoaderRef = scope.getApplicationLoader();
TypeReference typeRef = TypeReference.findOrCreate(appLoaderRef, coreName);
IClass coreClass = cha.lookupClass(typeRef);
if (coreClass == null)
{
String msg = "Failed to load a core's `IClass`: " + coreName;
throw new IllegalArgumentException(msg);
}
return coreClass;
}
开发者ID:paninij,项目名称:paninij,代码行数:20,代码来源:WalaUtil.java
示例6: getCapsuleMockupClassReference
import com.ibm.wala.types.ClassLoaderReference; //导入依赖的package包/类
public static TypeReference getCapsuleMockupClassReference(TypeReference capsuleInterface)
{
ClassLoaderReference loader = capsuleInterface.getClassLoader();
TypeName interfaceName = capsuleInterface.getName();
String pkg = interfaceName.getPackage().toString();
String name = interfaceName.getClassName().toString() + CAPSULE_MOCKUP_SUFFIX;
return TypeReference.findOrCreateClass(loader, pkg, name);
}
开发者ID:paninij,项目名称:paninij,代码行数:11,代码来源:PaniniModel.java
示例7: getClassLoaderFactory
import com.ibm.wala.types.ClassLoaderReference; //导入依赖的package包/类
@Override
protected ClassLoaderFactory getClassLoaderFactory(SetOfClasses exclusions) {
return new ECJClassLoaderFactory(exclusions) {
@Override
protected ECJSourceLoaderImpl makeSourceLoader(ClassLoaderReference classLoaderReference, IClassHierarchy cha, IClassLoader parent) {
return new ECJSourceLoaderImpl(classLoaderReference, parent, cha) {
@Override
protected SourceModuleTranslator getTranslator() {
return new ECJSourceModuleTranslator(cha.getScope(), this) {
@Override
protected JDTJava2CAstTranslator makeCAstTranslator(CompilationUnit astRoot, String fullPath) {
return new JDTJava2CAstTranslator<Position>(sourceLoader, astRoot, fullPath, true) {
@Override
public CAstEntity translateToCAst() {
CAstEntity ast = super.translateToCAst();
AstLoopUnwinder unwind = new AstLoopUnwinder(new CAstImpl(), true, unrollDepth);
return unwind.translate(ast);
}
@Override
public Position makePosition(int start, int end) {
try {
return new RangePosition(new URL("file://" + fullPath), this.cu.getLineNumber(start), start, end);
} catch (MalformedURLException e) {
throw new RuntimeException("bad file: " + fullPath, e);
}
}
};
}
};
}
};
}
};
}
开发者ID:wala,项目名称:MemSAT,代码行数:37,代码来源:MiniaturECJJavaAnalysisEngine.java
示例8: createIR
import com.ibm.wala.types.ClassLoaderReference; //导入依赖的package包/类
public Map<IMethod, IR> createIR() throws java.io.IOException {
Map<IMethod, IR> result = new HashMap<IMethod, IR>();
engine.buildAnalysisScope();
IClassHierarchy cha = engine.getClassHierarchy();
SSAOptions options = new SSAOptions();
IRFactory<IMethod> F = AstIRFactory.makeDefaultFactory();
for(Iterator<IClass> clss = cha.iterator(); clss.hasNext(); ) {
IClass cls = clss.next();
ClassLoaderReference clr = cls.getClassLoader().getReference();
if ( !(clr.equals(ClassLoaderReference.Primordial)
||
clr.equals(ClassLoaderReference.Extension)))
{
for (Iterator<IMethod> ms = cls.getDeclaredMethods().iterator();
ms.hasNext(); )
{
IMethod m = ms.next();
IR ir = F.makeIR(m, Everywhere.EVERYWHERE, options);
result.put(m, ir);
}
}
}
return result;
}
开发者ID:wala,项目名称:MemSAT,代码行数:30,代码来源:IRCreation.java
示例9: makeClassLoaderFactory
import com.ibm.wala.types.ClassLoaderReference; //导入依赖的package包/类
@Override
protected ClassLoaderFactory makeClassLoaderFactory(SetOfClasses exclusions) {
return new JDTClassLoaderFactory(exclusions) {
@Override
protected JDTSourceLoaderImpl makeSourceLoader(ClassLoaderReference classLoaderReference, IClassHierarchy cha, IClassLoader parent) {
return new JDTSourceLoaderImpl(classLoaderReference, parent, cha) {
@Override
protected SourceModuleTranslator getTranslator() {
return new JDTSourceModuleTranslator(cha.getScope(), this) {
@Override
protected JDTJava2CAstTranslator makeCAstTranslator(CompilationUnit astRoot, final IFile sourceFile, String fullPath) {
return new JDTJava2CAstTranslator(sourceLoader, astRoot, fullPath, true) {
@Override
public CAstEntity translateToCAst() {
CAstEntity ast = super.translateToCAst();
AstLoopUnwinder unwind = new AstLoopUnwinder(new CAstImpl(), true, unrollDepth);
return unwind.translate(ast);
}
@Override
public JdtPosition makePosition(int start, int end) {
return new JdtPosition(start, end, this.cu.getLineNumber(start), this.cu.getLineNumber(end), sourceFile, this.fullPath);
}
};
}
};
}
};
}
};
}
开发者ID:wala,项目名称:MemSAT,代码行数:32,代码来源:MiniaturJDTJavaAnalysisEngine.java
示例10: extractFingerPrints
import com.ibm.wala.types.ClassLoaderReference; //导入依赖的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: getApplicationClassesIterator
import com.ibm.wala.types.ClassLoaderReference; //导入依赖的package包/类
public static Iterator<IClass> getApplicationClassesIterator(IClassHierarchy classHierarchy)
{
IClassLoader appLoader = classHierarchy.getLoader(ClassLoaderReference.Application);
return appLoader.iterateAllClasses();
}
开发者ID:paninij,项目名称:paninij,代码行数:6,代码来源:JavaModel.java
示例12: getCallGraph
import com.ibm.wala.types.ClassLoaderReference; //导入依赖的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
注:本文中的com.ibm.wala.types.ClassLoaderReference类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论