final public void caseRefType(RefType t) { SootClass cl = t.getSootClass(); List<AllocNode> list; if ((list = class2allocs.get(cl)) == null) { list = new LinkedList<AllocNode>(); class2allocs.put(cl, list); } list.add(alloc); }
private void add_ThrownType(Type t) { if (t instanceof RefType) { curExceptionSet.add(((RefType) t).getSootClass()); } }
public boolean isClass() { if (type instanceof ArrayType || type instanceof NullType || (type instanceof RefType && !((RefType) type).getSootClass().isInterface())) { return true; } return false; }
private boolean hasNoHierarchy(RefType type) { final SootClass sootClass = type.getSootClass(); return !(sootClass.hasSuperclass() || JAVA_LANG_OBJECT_CLASS == sootClass); }
private static void initThrowables() { Scene sc = Scene.v(); throwable = new SootClass[10]; throwable[0] = sc.getRefType("java.lang.RuntimeException").getSootClass(); throwable[1] = sc.getRefType("java.lang.ArithmeticException").getSootClass(); throwable[2] = sc.getRefType("java.lang.ArrayStoreException").getSootClass(); throwable[3] = sc.getRefType("java.lang.ClassCastException").getSootClass(); throwable[4] = sc.getRefType("java.lang.IllegalMonitorStateException").getSootClass(); throwable[5] = sc.getRefType("java.lang.IndexOutOfBoundsException").getSootClass(); throwable[6] = sc.getRefType("java.lang.ArrayIndexOutOfBoundsException").getSootClass(); throwable[7] = sc.getRefType("java.lang.NegativeArraySizeException").getSootClass(); throwable[8] = sc.getRefType("java.lang.NullPointerException").getSootClass(); throwable[9] = sc.getRefType("java.lang.Throwable").getSootClass(); } }
/** * creates soot exceptions from polyglot throws */ private ArrayList<SootClass> createExceptions(polyglot.ast.ProcedureDecl procedure) { ArrayList<SootClass> exceptions = new ArrayList<SootClass>(); Iterator throwsIt = procedure.throwTypes().iterator(); while (throwsIt.hasNext()) { polyglot.types.Type throwType = ((polyglot.ast.TypeNode) throwsIt.next()).type(); exceptions.add(((soot.RefType) Util.getSootType(throwType)).getSootClass()); } return exceptions; }
public void visit(Node n) { Type t = n.getType(); if (t instanceof RefType) { RefType rt = (RefType) t; if (rt.getSootClass().isAbstract()) { return; } } ret.add(t); } });
public boolean containsClass(String className) { RefType type = nameToClass.get(className); if (type == null) { return false; } if (!type.hasSootClass()) { return false; } SootClass c = type.getSootClass(); return c.isInScene(); }
protected boolean isTypeLoaded(Type tp) { if (tp instanceof RefType) { RefType rt = (RefType) tp; if (rt.hasSootClass()) { return isClassLoaded(rt.getSootClass()); } } return false; }
protected void addToResolveWorklist(Type type, int level) { // We go from Type -> SootClass directly, since RefType.getSootClass // calls makeClassRef anyway if (type instanceof RefType) { addToResolveWorklist(((RefType) type).getSootClass(), level); } else if (type instanceof ArrayType) { addToResolveWorklist(((ArrayType) type).baseType, level); } // Other types ignored }
private void javafy_new_expr(ValueBox vb) { NewExpr ne = (NewExpr) vb.getValue(); String className = ne.getBaseType().getSootClass().toString(); String packageName = ne.getBaseType().getSootClass().getJavaPackageName(); String classPackageName = packageName; if (className.lastIndexOf('.') > 0) { // 0 doesnt make sense classPackageName = className.substring(0, className.lastIndexOf('.')); } if (!packageName.equals(classPackageName)) { throw new DecompilationException("Unable to retrieve package name for identifier. Please report to developer."); } addToImportList(className); }
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; }
private void resolveStaticTypes(Set<Type> s, InvokeCallSite ics) { ArrayTypes at = ics.reachingTypes(); for (Type bType : resolveToClasses(s)) { SootClass baseClass = ((RefType) bType).getSootClass(); Iterator<SootMethod> mIt = getPublicMethodIterator(baseClass, at); while (mIt.hasNext()) { SootMethod sm = mIt.next(); cm.addVirtualEdge(ics.container(), ics.stmt(), sm, Kind.REFL_INVOKE, null); } } }
protected ReferenceVariable staticFieldImpl(String className, String fieldName) { SootClass c = RefType.v(className).getSootClass(); SootField f = c.getFieldByName(fieldName); return pag.makeGlobalVarNode(f, f.getType()); }
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; }
protected void checkThrow(Body b, ThrowStmt ts) { if (isThrowDeclared(b, ((RefType) ts.getOp().getType()).getSootClass()) || isThrowFromCompiler(ts) || isExceptionCaught(b, ts, (RefType) ts.getOp().getType())) { return; } if (reporter != null) { reporter.reportError(new ExceptionCheckerError(b.getMethod(), ((RefType) ts.getOp().getType()).getSootClass(), ts, (SourceLnPosTag) ts.getOpBox().getTag("SourceLnPosTag"))); } }
private void loadBooleanValue(PatchingChain<Unit> units, SootField f, Unit insert) { units.insertBefore(Baf.v().newStaticGetInst(f.makeRef()), insert); if (f.getType() instanceof RefType) { SootMethod boolInit = ((RefType) f.getType()).getSootClass().getMethod("boolean booleanValue()"); units.insertBefore(Baf.v().newVirtualInvokeInst(boolInit.makeRef()), insert); } }
@Override public void visit(Node n) { if (n instanceof ClassConstantNode) { ClassConstantNode ccn = (ClassConstantNode) n; Type ccnType = ccn.getClassConstant().toSootType(); // If the referenced class has not been loaded, // we do this now SootClass targetClass = ((RefType) ccnType).getSootClass(); if (targetClass.resolvingLevel() == SootClass.DANGLING) { Scene.v().forceResolve(targetClass.getName(), SootClass.SIGNATURES); } edgeTgt.makeP2Set().add(pag.makeAllocNode(edgeSrc.getValue(), ccnType, ccn.getMethod())); addToWorklist(edgeTgt); } }
@Override public void visit(Node n) { if (n instanceof ClassConstantNode) { ClassConstantNode ccn = (ClassConstantNode) n; Type ccnType = ccn.getClassConstant().toSootType(); // If the referenced class has not been loaded, we do // this now SootClass targetClass = ((RefType) ccnType).getSootClass(); if (targetClass.resolvingLevel() == SootClass.DANGLING) { Scene.v().forceResolve(targetClass.getName(), SootClass.SIGNATURES); } instance.makeP2Set().add(pag.makeAllocNode(src.getValue(), ccnType, ccn.getMethod())); } }
private void insertCastOrBoxingCode(Local lhs, Local rhs, Chain<Unit> newUnits) { // if assigning to a primitive type then there's nothing to do if (lhs.getType() instanceof RefLikeType) { if ((rhs.getType() instanceof RefLikeType)) { // insert cast newUnits.add(Jimple.v().newAssignStmt(lhs, Jimple.v().newCastExpr(rhs, lhs.getType()))); } else { // primitive type in rhs; insert boxing code RefType boxedType = ((PrimType) rhs.getType()).boxedType(); SootMethodRef ref = Scene.v().makeMethodRef(boxedType.getSootClass(), "valueOf", Collections.<Type>singletonList(rhs.getType()), boxedType, true); newUnits.add(Jimple.v().newAssignStmt(lhs, Jimple.v().newStaticInvokeExpr(ref, rhs))); } } }