private boolean isCallClassSubClass(SootClass call, SootClass check) { if (!call.hasSuperclass()) { return false; } if (call.getSuperclass().equals(check)) { return true; } return false; }
private boolean hasNoHierarchy(RefType type) { final SootClass sootClass = type.getSootClass(); return !(sootClass.hasSuperclass() || JAVA_LANG_OBJECT_CLASS == sootClass); }
private boolean catches_Exception(IterableSet tryExceptionSet, SootClass c) { Iterator it = tryExceptionSet.iterator(); while (it.hasNext()) { SootClass thrownException = (SootClass) it.next(); while (true) { if (thrownException == c) { return true; } if (thrownException.hasSuperclass() == false) { break; } thrownException = thrownException.getSuperclass(); } } return false; }
private boolean handled_Exception(HashSet handledExceptions, SootClass c) { SootClass thrownException = c; if (is_HandledByRuntime(thrownException)) { return true; } if (handledExceptions == null) { return false; } while (true) { if (handledExceptions.contains(thrownException)) { return true; } if (thrownException.hasSuperclass() == false) { return false; } thrownException = thrownException.getSuperclass(); } }
public static List<SootField> getAllFields(SootClass sc) { // Get list of reachable methods declared in this class // Also get list of fields declared in this class List<SootField> allFields = new ArrayList<SootField>(); for (SootField field : sc.getFields()) { allFields.add(field); } // Add reachable methods and fields declared in superclasses SootClass superclass = sc; if (superclass.hasSuperclass()) { superclass = superclass.getSuperclass(); } while (superclass.hasSuperclass()) // we don't want to process Object { for (SootField scField : superclass.getFields()) { allFields.add(scField); } superclass = superclass.getSuperclass(); } return allFields; }
public static List<SootMethod> getAllReachableMethods(SootClass sc) { ReachableMethods rm = Scene.v().getReachableMethods(); // Get list of reachable methods declared in this class List<SootMethod> allMethods = new ArrayList<SootMethod>(); Iterator methodsIt = sc.methodIterator(); while (methodsIt.hasNext()) { SootMethod method = (SootMethod) methodsIt.next(); if (rm.contains(method)) { allMethods.add(method); } } // Add reachable methods declared in superclasses SootClass superclass = sc; if (superclass.hasSuperclass()) { superclass = superclass.getSuperclass(); } while (superclass.hasSuperclass()) // we don't want to process Object { Iterator scMethodsIt = superclass.methodIterator(); while (scMethodsIt.hasNext()) { SootMethod scMethod = (SootMethod) scMethodsIt.next(); if (rm.contains(scMethod)) { allMethods.add(scMethod); } } superclass = superclass.getSuperclass(); } return allMethods; }
private static Deque<RefType> superclassPath(RefType t, RefType anchor) { Deque<RefType> r = new ArrayDeque<RefType>(); r.addFirst(t); if (TypeResolver.typesEqual(t, anchor)) { return r; } SootClass sc = t.getSootClass(); while (sc.hasSuperclass()) { sc = sc.getSuperclass(); RefType cur = sc.getType(); r.addFirst(cur); if (TypeResolver.typesEqual(cur, anchor)) { break; } } if (!TypeResolver.typesEqual(r.getFirst(), anchor)) { r.addFirst(anchor); } return r; }
if (superclass.hasSuperclass()) { superclass = sootClass.getSuperclass(); while (superclass.hasSuperclass()) // we don't want to process Object
/** * Returns a list of <strong>direct</strong> superclasses of passed class in reverse order, starting with its parent. * * @param sootClass * the <strong>class</strong> of which superclasses will be taken. Must not be {@code null} or interface * @return list of superclasses * @throws IllegalArgumentException * when passed class is an interface * @throws NullPointerException * when passed argument is {@code null} */ public List<SootClass> getSuperclassesOf(SootClass sootClass) { sootClass.checkLevel(SootClass.HIERARCHY); if (sootClass.isInterface()) { throw new IllegalArgumentException(sootClass.getName() + " is an interface, but class is expected"); } checkState(); final List<SootClass> superclasses = new ArrayList<>(); SootClass current = sootClass; while (current.hasSuperclass()) { superclasses.add(current.getSuperclass()); current = current.getSuperclass(); } return Collections.unmodifiableList(superclasses); }
if (superclass.hasSuperclass()) { superclass = superclass.getSuperclass(); while (superclass.hasSuperclass()) { if (superclass.isApplicationClass()) { externalMethods.addAll(uf.getExtMethods(superclass)); if (superclass.hasSuperclass()) { superclass = superclass.getSuperclass(); while (superclass.hasSuperclass()) { if (superclass.isApplicationClass()) { externalFields.addAll(uf.getExtFields(superclass));
private boolean isRewritable(Trap t) { // ignore traps that already catch their own begin unit if (t.getBeginUnit() == t.getHandlerUnit()) { return false; } // ignore runtime try blocks - these may have weird side-effects do to asynchronous exceptions SootClass exc = t.getException(); if (exc.getName().equals("java.lang.Throwable")) { return false; } do { if (exc.getName().equals("java.lang.RuntimeException")) { return false; } } while (exc.hasSuperclass() && (exc = exc.getSuperclass()) != null); return true; } }
private Set<SootClass> getParentsOfIncluding(Collection<SootClass> classes) { final Set<SootClass> parents = new HashSet<>(classes); for (SootClass clazz : classes) { // add implementing interfaces parents.addAll(clazz.getInterfaces()); // add extending class if any if (!clazz.isInterface() && clazz.hasSuperclass()) { parents.add(clazz.getSuperclass()); } // and superclasses (superinterfaces) of passed applicationClass parents.addAll(clazz.isInterface() ? Scene.v().getActiveHierarchy().getSuperinterfacesOfIncluding(clazz) : Scene.v().getActiveHierarchy().getSuperclassesOfIncluding(clazz)); } return parents; }
private boolean is_HandledByRuntime(SootClass c) { SootClass thrownException = c, runtimeException = Scene.v().getSootClass("java.lang.RuntimeException"), error = Scene.v().getSootClass("java.lang.Error"); while (true) { if ((thrownException == runtimeException) || (thrownException == error)) { return true; } if (thrownException.hasSuperclass() == false) { return false; } thrownException = thrownException.getSuperclass(); } } }
private List<SootClass> getParentsOfIncluding(SootClass applicationClass) { // result contains of interfaces that implements passed applicationClass final List<SootClass> result = HierarchyUtils.getAllInterfacesOf(applicationClass); // add implementing interfaces result.addAll(applicationClass.getInterfaces()); // add extending class if any if (!applicationClass.isInterface() && applicationClass.hasSuperclass()) { result.add(applicationClass.getSuperclass()); } // and superclasses (superinterfaces) of passed applicationClass result.addAll( applicationClass.isInterface() ? Scene.v().getActiveHierarchy().getSuperinterfacesOfIncluding(applicationClass) : Scene.v().getActiveHierarchy().getSuperclassesOfIncluding(applicationClass)); return result; }
private boolean catches_RuntimeException(SootClass c) { if ((c == Scene.v().getSootClass("java.lang.Throwable")) || (c == Scene.v().getSootClass("java.lang.Exception"))) { return true; } SootClass caughtException = c, runtimeException = Scene.v().getSootClass("java.lang.RuntimeException"); while (true) { if (caughtException == runtimeException) { return true; } if (caughtException.hasSuperclass() == false) { return false; } caughtException = caughtException.getSuperclass(); } } }
return; if (currClass.hasSuperclass() && !currClass.getSuperclass().isPhantom() && !currClass.getSuperclass().getName().equals("java.lang.Object")) { currClass = currClass.getSuperclass();
if (superclass.hasSuperclass()) { superclass = sm.getDeclaringClass().getSuperclass(); while (superclass.hasSuperclass()) // we don't want to process Object
String superClass = c.hasSuperclass() ? SootToDexUtils.getDexTypeDescriptor(c.getSuperclass().getType()) : null;
outer: do { while (!c.getName().equals("java.lang.ClassLoader")) { if (!c.hasSuperclass()) { break outer;
} else { while (curClass.hasSuperclass()) { curClass = curClass.getSuperclass(); if (type instanceof RefType && curClass.isPhantom()) {