/** * Given a set of definite receiver types, returns a list of possible targets. */ public List<SootMethod> resolveConcreteDispatch(List<Type> classes, SootMethod m) { m.getDeclaringClass().checkLevel(SootClass.HIERARCHY); checkState(); Set<SootMethod> s = new ArraySet<SootMethod>(); for (Type cls : classes) { if (cls instanceof RefType) { s.add(resolveConcreteDispatch(((RefType) cls).getSootClass(), m)); } else if (cls instanceof ArrayType) { s.add(resolveConcreteDispatch((RefType.v("java.lang.Object")).getSootClass(), m)); } else { throw new RuntimeException("Unable to resolve concrete dispatch of type " + cls); } } return Collections.unmodifiableList(new ArrayList<SootMethod>(s)); }
/** * Given an abstract dispatch to an object of type c and a method m, gives a list of possible receiver methods. */ public List<SootMethod> resolveAbstractDispatch(SootClass c, SootMethod m) { c.checkLevel(SootClass.HIERARCHY); m.getDeclaringClass().checkLevel(SootClass.HIERARCHY); checkState(); Set<SootMethod> s = new ArraySet<SootMethod>(); Collection<SootClass> classesIt; if (c.isInterface()) { Set<SootClass> classes = new HashSet<SootClass>(); for (SootClass sootClass : getImplementersOf(c)) { classes.addAll(getSubclassesOfIncluding(sootClass)); } classesIt = classes; } else { classesIt = getSubclassesOfIncluding(c); } for (SootClass cl : classesIt) { if (!Modifier.isAbstract(cl.getModifiers())) { s.add(resolveConcreteDispatch(cl, m)); } } return Collections.unmodifiableList(new ArrayList<SootMethod>(s)); }
if (defClass != sc) { try { SootMethod rt_func = typeHierarchy.resolveConcreteDispatch(sc, func); if (rt_func != func) { it.remove();
if (defClass != sc) { try { SootMethod rt_func = typeHierarchy.resolveConcreteDispatch(sc, func); if (rt_func != func) { it.remove();
if (defClass != sc) { try { SootMethod rt_func = typeHierarchy.resolveConcreteDispatch(sc, func); if (rt_func != func) { it.remove();
= hierarchy.resolveConcreteDispatch(maySootClass, method.getDeclaringClass().getMethodByName("run"));
/** Returns the target for the given SpecialInvokeExpr. */ public SootMethod resolveSpecialDispatch(SpecialInvokeExpr ie, SootMethod container) { container.getDeclaringClass().checkLevel(SootClass.HIERARCHY); SootMethod target = ie.getMethod(); target.getDeclaringClass().checkLevel(SootClass.HIERARCHY); /* * This is a bizarre condition! Hopefully the implementation is correct. See VM Spec, 2nd Edition, Chapter 6, in the * definition of invokespecial. */ if ("<init>".equals(target.getName()) || target.isPrivate()) { return target; } else if (isClassSubclassOf(target.getDeclaringClass(), container.getDeclaringClass())) { return resolveConcreteDispatch(container.getDeclaringClass(), target); } else { return target; } } }
/** Given a set of definite receiver types, returns a list of possible targets. */ public List resolveConcreteDispatch(List classes, SootMethod m) { m.getDeclaringClass().checkLevel(SootClass.HIERARCHY); checkState(); ArraySet s = new ArraySet(); Iterator classesIt = classes.iterator(); while (classesIt.hasNext()) { Object cls = classesIt.next(); if (cls instanceof RefType) s.add(resolveConcreteDispatch(((RefType)cls).getSootClass(), m)); else if (cls instanceof ArrayType) { s.add(resolveConcreteDispatch((RefType.v("java.lang.Object")).getSootClass(), m)); } else throw new RuntimeException("Unable to resolve concrete dispatch of type "+ cls); } List l = new ArrayList(); l.addAll(s); return Collections.unmodifiableList(l); }
/** Given a set of definite receiver types, returns a list of possible targets. */ public List resolveConcreteDispatch(List classes, SootMethod m) { m.getDeclaringClass().checkLevel(SootClass.HIERARCHY); checkState(); ArraySet s = new ArraySet(); Iterator classesIt = classes.iterator(); while (classesIt.hasNext()) { Object cls = classesIt.next(); if (cls instanceof RefType) s.add(resolveConcreteDispatch(((RefType)cls).getSootClass(), m)); else if (cls instanceof ArrayType) { s.add(resolveConcreteDispatch((RefType.v("java.lang.Object")).getSootClass(), m)); } else throw new RuntimeException("Unable to resolve concrete dispatch of type "+ cls); } List l = new ArrayList(); l.addAll(s); return Collections.unmodifiableList(l); }
/** Given an abstract dispatch to an object of type c and a method m, gives * a list of possible receiver methods. */ public List resolveAbstractDispatch(SootClass c, SootMethod m) { c.checkLevel(SootClass.HIERARCHY); m.getDeclaringClass().checkLevel(SootClass.HIERARCHY); checkState(); Iterator<SootClass> classesIt = null; if (c.isInterface()) { classesIt = getImplementersOf(c).iterator(); HashSet<SootClass> classes = new HashSet<SootClass>(); while (classesIt.hasNext()) classes.addAll(getSubclassesOfIncluding(classesIt.next())); classesIt = classes.iterator(); } else classesIt = getSubclassesOfIncluding(c).iterator(); ArraySet s = new ArraySet(); while (classesIt.hasNext()) { SootClass cl = classesIt.next(); if( Modifier.isAbstract( cl.getModifiers() ) ) continue; s.add(resolveConcreteDispatch(cl, m)); } List l = new ArrayList(); l.addAll(s); return Collections.unmodifiableList(l); }
/** Given an abstract dispatch to an object of type c and a method m, gives * a list of possible receiver methods. */ public List resolveAbstractDispatch(SootClass c, SootMethod m) { c.checkLevel(SootClass.HIERARCHY); m.getDeclaringClass().checkLevel(SootClass.HIERARCHY); checkState(); Iterator<SootClass> classesIt = null; if (c.isInterface()) { classesIt = getImplementersOf(c).iterator(); HashSet<SootClass> classes = new HashSet<SootClass>(); while (classesIt.hasNext()) classes.addAll(getSubclassesOfIncluding(classesIt.next())); classesIt = classes.iterator(); } else classesIt = getSubclassesOfIncluding(c).iterator(); ArraySet s = new ArraySet(); while (classesIt.hasNext()) { SootClass cl = classesIt.next(); if( Modifier.isAbstract( cl.getModifiers() ) ) continue; s.add(resolveConcreteDispatch(cl, m)); } List l = new ArrayList(); l.addAll(s); return Collections.unmodifiableList(l); }
/** Returns the target for the given SpecialInvokeExpr. */ public SootMethod resolveSpecialDispatch(SpecialInvokeExpr ie, SootMethod container) { container.getDeclaringClass().checkLevel(SootClass.HIERARCHY); SootMethod target = ie.getMethod(); target.getDeclaringClass().checkLevel(SootClass.HIERARCHY); /* This is a bizarre condition! Hopefully the implementation is correct. See VM Spec, 2nd Edition, Chapter 6, in the definition of invokespecial. */ if (target.getName().equals("<init>") || target.isPrivate()) return target; else if (isClassSubclassOf(target.getDeclaringClass(), container.getDeclaringClass())) return resolveConcreteDispatch(container.getDeclaringClass(), target); else return target; } }
/** Returns the target for the given SpecialInvokeExpr. */ public SootMethod resolveSpecialDispatch(SpecialInvokeExpr ie, SootMethod container) { container.getDeclaringClass().checkLevel(SootClass.HIERARCHY); SootMethod target = ie.getMethod(); target.getDeclaringClass().checkLevel(SootClass.HIERARCHY); /* This is a bizarre condition! Hopefully the implementation is correct. See VM Spec, 2nd Edition, Chapter 6, in the definition of invokespecial. */ if (target.getName().equals("<init>") || target.isPrivate()) return target; else if (isClassSubclassOf(target.getDeclaringClass(), container.getDeclaringClass())) return resolveConcreteDispatch(container.getDeclaringClass(), target); else return target; } }