public void addMethod(IMethod method) { if (this.methods.containsKey(method.getSelector())) { // TODO: Check this matches on signature not on contents! // TODO: What on different Context versions throw new IllegalStateException("The AndroidModelClass already contains a Method called" + method.getName()); } assert(this.methods != null); this.methods.put(method.getSelector(), method); }
public void addMethod(IMethod method) { if (this.methods.containsKey(method.getSelector())) { // TODO: Check this matches on signature not on contents! // TODO: What on different Context versions throw new IllegalStateException("The AndroidModelClass already contains a Method called" + method.getName()); } assert(this.methods != null); this.methods.put(method.getSelector(), method); }
public boolean containsMethod(Selector selector) { return ( ((macroModel != null) && macroModel.getSelector().equals(selector)) || methods.containsKey(selector)); }
@Override public IMethod getMethod(Selector selector) throws UnsupportedOperationException { for (IMethod m : methods) { if (m.getSelector().equals(selector)) { return m; } } return null; }
@Override public IMethod getMethod(Selector selector) throws UnsupportedOperationException { for (IMethod m : methods) { if (m.getSelector().equals(selector)) { return m; } } return null; }
public boolean containsMethod(Selector selector) { return ( ((macroModel != null) && macroModel.getSelector().equals(selector)) || methods.containsKey(selector)); }
@Override public IMethod getMethod(Selector selector) { //assert (macroModel != null) : "Macro Model was not set yet!"; if ((macroModel != null) && (macroModel.getSelector().equals(selector))) { return macroModel; } if (methods.containsKey(selector)) { return methods.get(selector); } if (selector.equals(MethodReference.initSelector)) { logger.warn("AndroidModelClass is not intended to be initialized"); return null; } throw new IllegalArgumentException("Could not resolve " + selector); }
@Override public IMethod getMethod(Selector selector) { //assert (macroModel != null) : "Macro Model was not set yet!"; if ((macroModel != null) && (macroModel.getSelector().equals(selector))) { return macroModel; } if (methods.containsKey(selector)) { return methods.get(selector); } if (selector.equals(MethodReference.initSelector)) { logger.warn("AndroidModelClass is not intended to be initialized"); return null; } throw new IllegalArgumentException("Could not resolve " + selector); }
/** * 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; }
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 }
@Override public void act(int i) { InstanceKey I = system.getInstanceKey(i); IClass C = I.getConcreteType(); if ((C.getMethod(targetMethod.getSelector()) == targetMethod) == sense) { if (L.add(i)) { result = true; } } } }
@Override public void act(int i) { InstanceKey I = system.getInstanceKey(i); IClass C = I.getConcreteType(); if ((C.getMethod(targetMethod.getSelector()) == targetMethod) == sense) { if (L.add(i)) { result = true; } } } }
/** * Return the method that m overrides, or null if none */ public static IMethod getOverriden(IMethod m) { IClass c = m.getDeclaringClass(); IClass parent = c.getSuperclass(); if (parent == null) { return null; } else { MethodReference ref = MethodReference.findOrCreate(parent.getReference(), m.getSelector()); IMethod m2 = m.getClassHierarchy().resolveMethod(ref); if (m2 != null && !m2.equals(m)) { return m2; } return null; } }
/** * Get all non-constructor, non-class-initializer methods declared by a class * if their name is equal to the specified name. * @param cls the class * @param name the name */ private static Collection<IMethod> getDeclaredNormalMethods(IClass cls,Atom name) { Collection<IMethod> result = HashSetFactory.make(); for (IMethod m : cls.getDeclaredMethods()) { if (!m.isInit() && !m.isClinit() && m.getSelector().getName().equals(name)) { result.add(m); } } return result; }
/** * Get all non-constructor, non-class-initializer methods declared by a class * if their name is equal to the specified name. * @param cls the class * @param name the name */ private static Collection<IMethod> getDeclaredNormalMethods(IClass cls,Atom name) { Collection<IMethod> result = HashSetFactory.make(); for (IMethod m : cls.getDeclaredMethods()) { if (!m.isInit() && !m.isClinit() && m.getSelector().getName().equals(name)) { result.add(m); } } return result; }
/** * Return the method that m overrides, or null if none */ public static IMethod getOverriden(IMethod m) { IClass c = m.getDeclaringClass(); IClass parent = c.getSuperclass(); if (parent == null) { return null; } else { MethodReference ref = MethodReference.findOrCreate(parent.getReference(), m.getSelector()); IMethod m2 = m.getClassHierarchy().resolveMethod(ref); if (m2 != null && !m2.equals(m)) { return m2; } return null; } }
/** * find the root of the inheritance tree for method m. */ public static IMethod getRootOfInheritanceTree(IMethod m) { IClass c = m.getDeclaringClass(); IClass parent = c.getSuperclass(); if (parent == null) { return m; } else { MethodReference ref = MethodReference.findOrCreate(parent.getReference(), m.getSelector()); IMethod m2 = m.getClassHierarchy().resolveMethod(ref); if (m2 != null && !m2.equals(m)) { return getRootOfInheritanceTree(m2); } return m; } }
/** * Get all non-constructor, non-class-initializer methods declared by a class * and all its superclasses if their name is equal to the specified name. * @param cls the class * @param name the name */ private static Collection<IMethod> getAllNormalPublicMethods(IClass cls,Atom name) { Collection<IMethod> result = HashSetFactory.make(); Collection<? extends IMethod> allMethods = null; allMethods = cls.getAllMethods(); for (IMethod m : allMethods) { if (!m.isInit() && !m.isClinit() && m.isPublic() && m.getSelector().getName().equals(name)) { result.add(m); } } return result; }
/** * find the root of the inheritance tree for method m. */ public static IMethod getRootOfInheritanceTree(IMethod m) { IClass c = m.getDeclaringClass(); IClass parent = c.getSuperclass(); if (parent == null) { return m; } else { MethodReference ref = MethodReference.findOrCreate(parent.getReference(), m.getSelector()); IMethod m2 = m.getClassHierarchy().resolveMethod(ref); if (m2 != null && !m2.equals(m)) { return getRootOfInheritanceTree(m2); } return m; } }
/** * Get all non-constructor, non-class-initializer methods declared by a class * and all its superclasses if their name is equal to the specified name. * @param cls the class * @param name the name */ private static Collection<IMethod> getAllNormalPublicMethods(IClass cls,Atom name) { Collection<IMethod> result = HashSetFactory.make(); Collection<? extends IMethod> allMethods = null; allMethods = cls.getAllMethods(); for (IMethod m : allMethods) { if (!m.isInit() && !m.isClinit() && m.isPublic() && m.getSelector().getName().equals(name)) { result.add(m); } } return result; }