private SootMethodRef getNewMethodRef(SootMethod method) { Map<SootMethod, SootMethodRef> methods = libClassesToMethods.computeIfAbsent(method.getDeclaringClass(), key -> new HashMap<>()); return methods.get(method); }
private void setNewMethodRef(SootMethod sm, SootMethodRef smr) { Map<SootMethod, SootMethodRef> methods = libClassesToMethods.computeIfAbsent(sm.getDeclaringClass(), key -> new HashMap<>()); methods.put(sm, smr); }
/** * We rely on the JDK class recognition to decide if a method is JDK method. */ public boolean isJavaLibraryMethod() { SootClass cl = getDeclaringClass(); return cl.isJavaLibraryClass(); }
public void precompute() { for (AbstractRuntimeThread thread : threads) { for (Object item : thread.getRunMethods()) { SootMethod runMethod = (SootMethod) item; if (runMethod.getDeclaringClass().isApplicationClass()) { getClassLocalObjectsAnalysis(runMethod.getDeclaringClass()); } } } }
private void addNodeTag(Node node, SootMethod m) { if (nodeToTag != null) { Tag tag; if (m == null) { tag = new StringTag(node.toString()); } else { tag = new LinkTag(node.toString(), m, m.getDeclaringClass().getName()); } nodeToTag.put(node, tag); } }
/** * Returns a list of possible targets for the given method and set of receiver types. */ public List<SootMethod> resolveAbstractDispatch(List<SootClass> classes, SootMethod m) { m.getDeclaringClass().checkLevel(SootClass.HIERARCHY); Set<SootMethod> s = new ArraySet<SootMethod>(); for (SootClass sootClass : classes) { s.addAll(resolveAbstractDispatch(sootClass, m)); } return Collections.unmodifiableList(new ArrayList<SootMethod>(s)); }
public boolean isObjectLocalToParent(Value localOrRef, SootMethod sm) { // Handle obvious case if (localOrRef instanceof StaticFieldRef) { return false; } ClassLocalObjectsAnalysis cloa = getClassLocalObjectsAnalysis(sm.getDeclaringClass()); return cloa.isObjectLocal(localOrRef, sm); }
public SmartMethodInfoFlowAnalysis getMethodInfoFlowAnalysis(SootMethod sm) { ClassInfoFlowAnalysis cdfa = getClassInfoFlowAnalysis(sm.getDeclaringClass()); return cdfa.getMethodInfoFlowAnalysis(sm); }
public SootMethod resolveSpecial(SpecialInvokeExpr iie, NumberedString subSig, SootMethod container, boolean appOnly) { SootMethod target = iie.getMethod(); /* cf. JVM spec, invokespecial instruction */ if (Scene.v().getOrMakeFastHierarchy().canStoreType(container.getDeclaringClass().getType(), target.getDeclaringClass().getType()) && container.getDeclaringClass().getType() != target.getDeclaringClass().getType() && !target.getName().equals("<init>") && subSig != sigClinit) { return resolveNonSpecial(container.getDeclaringClass().getSuperclass().getType(), subSig, appOnly); } else { return target; } }
/** * Returns true if an access to <code>target</code> is legal from code in <code>container</code>. */ public static boolean isAccessLegal(SootMethod container, SootClass target) { return target.isPublic() || container.getDeclaringClass().getPackageName().equals(target.getPackageName()); }
/** * @param lvNode * @param cName * @param mName * @return */ private boolean isDefinedIn(LocalVarNode lvNode, String cName, String mName) { return lvNode.getMethod() != null && lvNode.getMethod().getDeclaringClass().getName().equals(cName) && lvNode.getMethod().getName().equals(mName); }
public static String makeLabel(LocalVarNode n) { SootMethod sm = n.getMethod(); return "LV " + n.getVariable().toString() + " " + n.getNumber() + "\\n" + sm.getDeclaringClass() + "\\n" + sm.getName(); }
public CPApplication(ASTMethodNode AST, HashMap<String, Object> constantValueFields, HashMap<String, SootField> classNameFieldNameToSootFieldMapping) { className = AST.getDavaBody().getMethod().getDeclaringClass().getName(); cp = new CP(AST, constantValueFields, classNameFieldNameToSootFieldMapping); }
public CPApplication(boolean verbose, ASTMethodNode AST, HashMap<String, Object> constantValueFields, HashMap<String, SootField> classNameFieldNameToSootFieldMapping) { super(verbose); className = AST.getDavaBody().getMethod().getDeclaringClass().getName(); cp = new CP(AST, constantValueFields, classNameFieldNameToSootFieldMapping); }
private Iterator getScopedFields() { // get the fields for this class and store them SootClass sootClass = methodNode.getDavaBody().getMethod().getDeclaringClass(); fields = sootClass.getFields(); return fields.iterator(); }
final public Node caseThis() { VarNode ret = pag.makeLocalVarNode(new Pair<SootMethod, String>(method, PointsToAnalysis.THIS_NODE), method.getDeclaringClass().getType(), method); ret.setInterProcTarget(); return ret; }
protected void internalTransform(Body b, String phaseName, Map<String, String> options) { initialize(options); SootMethod meth = b.getMethod(); if ((methodsToPrint == null) || (meth.getDeclaringClass().getName() == methodsToPrint.get(meth.getName()))) { Body body = ir.getBody((JimpleBody) b); print_cfg(body); } }
/** * Returns true if the given method is visible to client code. */ private static boolean visible(SootMethod mPrime) { SootClass cPrime = mPrime.getDeclaringClass(); return (cPrime.isPublic() || cPrime.isProtected() || (!cPrime.isPrivate() && !ASSUME_PACKAGES_SEALED)) && (mPrime.isPublic() || mPrime.isProtected() || (!mPrime.isPrivate() && !ASSUME_PACKAGES_SEALED)); } }
/** * Local Class Decl - Local Inner Class */ private void createLocalClassDecl(polyglot.ast.LocalClassDecl cDecl) { BiMap lcMap = InitialResolver.v().getLocalClassMap(); String name = Util.getSootType(cDecl.decl().type()).toString(); if (!InitialResolver.v().hasClassInnerTag(body.getMethod().getDeclaringClass(), name)) { Util.addInnerClassTag(body.getMethod().getDeclaringClass(), name, null, cDecl.decl().name(), Util.getModifier(cDecl.decl().flags())); } }
/** * adds this field for the outer class */ private void handleOuterClassThisInit(soot.SootMethod sootMethod) { // static inner classes are different SootField this0Field = body.getMethod().getDeclaringClass().getFieldByNameUnsafe("this$0"); if (this0Field != null) { soot.jimple.FieldRef fieldRef = soot.jimple.Jimple.v().newInstanceFieldRef(specialThisLocal, this0Field.makeRef()); soot.jimple.AssignStmt stmt = soot.jimple.Jimple.v().newAssignStmt(fieldRef, outerClassParamLocal); body.getUnits().add(stmt); } }