public boolean isClass() { if (type instanceof ArrayType || type instanceof NullType || (type instanceof RefType && !((RefType) type).getSootClass().isInterface())) { return true; } return false; }
/** Returns true if this class is not an interface and not abstract. */ public boolean isConcrete() { return !isInterface() && !isAbstract(); }
/** Returns a list of direct subinterfaces of c, including itself. */ public List<SootClass> getDirectSubinterfacesOfIncluding(SootClass c) { c.checkLevel(SootClass.HIERARCHY); if (!c.isInterface()) { throw new RuntimeException("interface needed!"); } checkState(); List<SootClass> l = new ArrayList<SootClass>(); l.addAll(interfaceToDirSubinterfaces.get(c)); l.add(c); return Collections.unmodifiableList(l); }
/** Returns a list of subclasses of c, including itself. */ public List<SootClass> getSubclassesOfIncluding(SootClass c) { c.checkLevel(SootClass.HIERARCHY); if (c.isInterface()) { throw new RuntimeException("class needed!"); } List<SootClass> l = new ArrayList<SootClass>(); l.addAll(getSubclassesOf(c)); l.add(c); return Collections.unmodifiableList(l); }
/** Returns a list of superinterfaces of c, including itself. */ public List<SootClass> getSuperinterfacesOfIncluding(SootClass c) { c.checkLevel(SootClass.HIERARCHY); if (!c.isInterface()) { throw new RuntimeException("interface needed!"); } List<SootClass> l = new ArrayList<SootClass>(); l.addAll(getSuperinterfacesOf(c)); l.add(c); return Collections.unmodifiableList(l); }
/** Returns a list of direct subclasses of c, including c. */ public List<SootClass> getDirectSubclassesOfIncluding(SootClass c) { c.checkLevel(SootClass.HIERARCHY); if (c.isInterface()) { throw new RuntimeException("class needed!"); } checkState(); List<SootClass> l = new ArrayList<SootClass>(); l.addAll(classToDirSubclasses.get(c)); l.add(c); return Collections.unmodifiableList(l); }
/** Returns a list of direct implementers of c, excluding itself. */ public List<SootClass> getDirectImplementersOf(SootClass i) { i.checkLevel(SootClass.HIERARCHY); if (!i.isInterface()) { throw new RuntimeException("interface needed; got " + i); } checkState(); return Collections.unmodifiableList(interfaceToDirImplementers.get(i)); }
/** Returns a list of direct subclasses of c, excluding c. */ public List<SootClass> getDirectSubclassesOf(SootClass c) { c.checkLevel(SootClass.HIERARCHY); if (c.isInterface()) { throw new RuntimeException("class needed!"); } checkState(); return Collections.unmodifiableList(classToDirSubclasses.get(c)); }
/** Returns a list of direct subinterfaces of c. */ public List<SootClass> getDirectSubinterfacesOf(SootClass c) { c.checkLevel(SootClass.HIERARCHY); if (!c.isInterface()) { throw new RuntimeException("interface needed!"); } checkState(); return interfaceToDirSubinterfaces.get(c); }
private Set<SootClass> getChildrenOfIncluding(Collection<SootClass> classes) { return Stream .concat(classes.stream().filter(c -> !c.getName().equals("java.lang.Object")) .map(c -> c.isInterface() ? Scene.v().getActiveHierarchy().getImplementersOf(c) : Scene.v().getActiveHierarchy().getSubclassesOf(c)) .flatMap(Collection::stream), classes.stream()) .collect(toSet()); }
@Override public void validate(SootClass sc, List<ValidationException> exceptions) { if (sc.isInterface() && sc.isEnum()) { exceptions.add(new ValidationException(sc, "Class is both an interface and an enum")); } if (sc.isSynchronized()) { exceptions.add(new ValidationException(sc, "Classes cannot be synchronized")); } }
/** Returns a list of implementers of c, excluding itself. */ public List<SootClass> getImplementersOf(SootClass i) { i.checkLevel(SootClass.HIERARCHY); if (!i.isInterface()) { throw new RuntimeException("interface needed; got " + i); } checkState(); ArraySet<SootClass> set = new ArraySet<SootClass>(); for (SootClass c : getSubinterfacesOfIncluding(i)) { set.addAll(getDirectImplementersOf(c)); } ArrayList<SootClass> l = new ArrayList<SootClass>(); l.addAll(set); return Collections.unmodifiableList(l); }
private static List<SootClass> getVisibleApplicationClasses(SootMethod visibleBy) { final List<SootClass> result = new ArrayList<>(); final Iterator<SootClass> applicationClassesIterator = Scene.v().getApplicationClasses().snapshotIterator(); while (applicationClassesIterator.hasNext()) { final SootClass applicationClass = applicationClassesIterator.next(); if (applicationClass.isConcrete() && !applicationClass.isInterface() && applicationClass.isPublic() && Scene.v().getActiveHierarchy().isVisible(applicationClass, visibleBy)) { result.add(applicationClass); } } return result; }
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; }
public JInterfaceInvokeExpr(Value base, SootMethodRef methodRef, List<? extends Value> args) { super(Jimple.v().newLocalBox(base), methodRef, new ValueBox[args.size()]); // Check that the method's class is resolved enough // CheckLevel returns without doing anything because we can be not 'done' resolving methodRef.declaringClass().checkLevelIgnoreResolving(SootClass.HIERARCHY); // now check if the class is valid if (!methodRef.declaringClass().isInterface() && !methodRef.declaringClass().isPhantom()) { throw new RuntimeException("Trying to create interface invoke expression for non-interface type: " + methodRef.declaringClass() + " Use JVirtualInvokeExpr or JSpecialInvokeExpr instead!"); } for (int i = 0; i < args.size(); i++) { this.argBoxes[i] = Jimple.v().newImmediateBox(args.get(i)); } }
@Override public void caseVirtualInvokeInst(VirtualInvokeInst i) { SootMethodRef m = i.getMethodRef(); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, slashify(m.declaringClass().getName()), m.name(), toTypeDesc(m), m.declaringClass().isInterface()); }
@Override public void caseSpecialInvokeInst(SpecialInvokeInst i) { SootMethodRef m = i.getMethodRef(); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, slashify(m.declaringClass().getName()), m.name(), toTypeDesc(m), m.declaringClass().isInterface()); }
private boolean isSuitableClassToAddFieldConstant(SootClass sc, Constant constant) { if (sc.isInterface()) { return false; } if (constant instanceof ClassConstant) { ClassConstant classConstant = (ClassConstant) constant; RefType type = (RefType) classConstant.toSootType(); SootClass classFromConstant = type.getSootClass(); Hierarchy hierarchy = Scene.v().getActiveHierarchy(); return hierarchy.isVisible(sc, classFromConstant); } return true; }
@Override public void caseStaticInvokeInst(StaticInvokeInst i) { SootMethodRef m = i.getMethodRef(); mv.visitMethodInsn(Opcodes.INVOKESTATIC, slashify(m.declaringClass().getName()), m.name(), toTypeDesc(m), m.declaringClass().isInterface() && !m.isStatic()); }
public boolean isExceptionPointer(Node v) { if (v.getType() instanceof RefType) { SootClass sc = ((RefType) v.getType()).getSootClass(); if (!sc.isInterface() && Scene.v().getActiveHierarchy().isClassSubclassOfIncluding(sc, Constants.exeception_type.getSootClass())) { return true; } } return false; }