本文整理汇总了Java中com.ibm.wala.classLoader.IClass类的典型用法代码示例。如果您正苦于以下问题:Java IClass类的具体用法?Java IClass怎么用?Java IClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IClass类属于com.ibm.wala.classLoader包,在下文中一共展示了IClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIMethod
import com.ibm.wala.classLoader.IClass; //导入依赖的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
}
示例2: getLayoutClass
import com.ibm.wala.classLoader.IClass; //导入依赖的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;
}
示例3: main
import com.ibm.wala.classLoader.IClass; //导入依赖的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());
}
}
}
}
}
示例4: isInitialNodeByCallSite
import com.ibm.wala.classLoader.IClass; //导入依赖的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;
}
示例5: makeAll
import com.ibm.wala.classLoader.IClass; //导入依赖的package包/类
/**
* Returns a set of all of the entrypoints on the given capsule core.
*
* @param core A well-formed capsule core class, annotated with `@Capsule`.
*/
public static Set<Entrypoint> makeAll(IClass core)
{
assert isCapsuleCore(core);
Set<Entrypoint> entrypoints = HashSetFactory.make();
final Consumer<IMethod> addEntrypoint = (m -> entrypoints.add(new CapsuleCoreEntrypoint(m)));
// The way in which `entrypoints` is populated depends on whether the capsule core
// defines an active or passive capsule. If active, then the only entrypoint is `run()`.
// If passive, then every procedure is an entrypoint.
IMethod runDecl = getRunDecl(core);
if (runDecl != null) {
addEntrypoint.accept(runDecl);
} else {
getProceduresList(core).forEach(addEntrypoint);
}
return entrypoints;
}
示例6: processClass
import com.ibm.wala.classLoader.IClass; //导入依赖的package包/类
private void processClass(List<TypeLabel> filteredList,
TargetApplication targetApplication,
Map<String, AnalysisResult> analysisResult, IClass clazz) {
for (IMethod m : clazz.getDeclaredMethods()) {
try {
AnalyzedMethod method = targetApplication.findIRMethodForMethod(m);
if (method != null) {
MethodAnalyzer analyzer = new MethodAnalyzer(method, filteredList);
AnalysisResult candidates = analyzer.analyze();
if (!candidates.isEmpty()) {
analysisResult.put(m.getSignature(), candidates);
}
} else {
LOG.error("method is skipped");
}
} catch (Exception e) {
FileUtil.handleError(e, m.getSignature());
}
}
}
示例7: main
import com.ibm.wala.classLoader.IClass; //导入依赖的package包/类
/**
* main method to print out all ir for the test classes
* @param args no args defined
* @throws IOException
* @throws WalaException
*/
public static void main(String[] args) throws IOException, WalaException {
String pathname = TARGET_IRS;
if (args.length > 0) {
pathname = args[0];
}
TargetApplication targetApplication = TestUtilities.loadTestJar();
for (IClass clazz : targetApplication.getApplicationClasses()) {
for (IMethod m : clazz.getDeclaredMethods()) {
printToPDF(pathname, targetApplication.getClassHierachy(), targetApplication.findIRForMethod(m));
}
}
}
示例8: lookUpClass
import com.ibm.wala.classLoader.IClass; //导入依赖的package包/类
protected static IClass lookUpClass(String name) {
checkNotNull(name, "name of class must not be null");
if (testClassMap == null) {
initTestClasses();
}
IClass cl = testClassMap.get(name);
if (cl != null) {
return cl;
} else {
throw new IllegalArgumentException(
String.format("no class with name '%s' could be found in "
+ "the test class hierachie",
name));
}
}
示例9: createMethodFor
import com.ibm.wala.classLoader.IClass; //导入依赖的package包/类
private AnalyzedMethod createMethodFor(String className, String methodName, String jarName) {
TargetApplication application = TestUtilities.loadTestJar("target/" + jarName);
for (IClass cl : application.getClassHierachy()) {
if (cl.getName().toString().endsWith(className)) {
LOG.info("found class {}", className);
for (IMethod m : cl.getAllMethods()) {
if (m.getName().toString().equals(methodName) || m.getSignature().equals(methodName)) {
try {
PrintTestIRs.printToPDF("target", application.getClassHierachy(), application.findIRForMethod(m));
} catch (WalaException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
LOG.info("found method {}; {}", m.getSignature());
return application.findIRMethodForMethod(m);
}
}
}
}
throw new IllegalStateException(String.format("no method found %s %s", className, methodName));
}
示例10: getMethodByName
import com.ibm.wala.classLoader.IClass; //导入依赖的package包/类
/**
* Looks up a method by name in a class object. If the method is overloaded,
* the first one found is returned.
* @param clazz IClass object
* @param methodName name of the method to be looked up
* @return IMethod if method is declared in clazz, null otherwise
*/
public static IMethod getMethodByName(IClass clazz, String methodName) {
for (IMethod m: clazz.getAllMethods()) { // DeclaredMethods()) -> only impl./overriden methods
if (m.getSelector().toString().startsWith(methodName)) {
return m;
}
}
return null;
}
示例11: resolveMethod
import com.ibm.wala.classLoader.IClass; //导入依赖的package包/类
/**
* Hierarchical lookup of an {@link IMethod} via {@link IClass} and {@link CallSiteReference}.
* @param clazz the {@link IClass} to start with
* @param csr the {@link CallSiteReference}
* @return a {@link IMethod} object of the resolved method or null
*/
public static IMethod resolveMethod(IClass clazz, CallSiteReference csr) {
IMethod targetMethod = null;
while (targetMethod == null && !WalaUtils.isObjectClass(clazz)) {
targetMethod = clazz.getMethod(csr.getDeclaredTarget().getSelector());
if (targetMethod != null)
break;
clazz = clazz.getSuperclass();
}
return targetMethod;
}
示例12: collectAllInterfaces
import com.ibm.wala.classLoader.IClass; //导入依赖的package包/类
/**
* Collects all implemented interfaces for a given class
* @param clazz the IClass object to analyze
* @return a set of IClass objects representing the interfaces
*/
public static Set<IClass> collectAllInterfaces(IClass clazz) {
// do not check array classes
if (clazz.isArrayClass()) return new HashSet<IClass>();
Set<IClass> interfaces = new HashSet<IClass>(clazz.getDirectInterfaces());
for (IClass c : clazz.getDirectInterfaces())
interfaces.addAll(collectAllInterfaces(c));
return interfaces;
}
示例13: lookupClass
import com.ibm.wala.classLoader.IClass; //导入依赖的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;
}
示例14: isAppClass
import com.ibm.wala.classLoader.IClass; //导入依赖的package包/类
public static boolean isAppClass(IClass clazz) {
// Normalization:
// filter empty dummy classes
// possibly related too: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4295934
boolean isEmptyInnerClass = WalaUtils.isInnerClass(clazz)
&& isAnonymousInnerClass(clazz)
&& (clazz.getDeclaredMethods().isEmpty() ||
(clazz.getDeclaredMethods().size() == 1 && clazz.getDeclaredMethods().iterator().next().isClinit())
&& clazz.getDeclaredInstanceFields().isEmpty()
&& clazz.getDeclaredStaticFields().isEmpty()
&& clazz.getDirectInterfaces().isEmpty());
return clazz.getClassHierarchy().getScope().isApplicationLoader(clazz.getClassLoader()) && !isAndroidResourceClass(clazz) && !isEmptyInnerClass && !clazz.isSynthetic();
}
示例15: getSuperClassesIncluding
import com.ibm.wala.classLoader.IClass; //导入依赖的package包/类
/**
* Retrieves all superclasses for a given class including itself
* @param clazz the input IClass object
* @return a list of IClass superclass objects including the input class
*/
public static List<IClass> getSuperClassesIncluding(IClass clazz) {
LinkedList<IClass> superclasses = new LinkedList<IClass>(getSuperClasses(clazz));
superclasses.addFirst(clazz);
return superclasses;
}