private boolean examineInvokeExpr(InvokeExpr e) { List<Value> args = e.getArgs(); List<Type> argTypes = e.getMethodRef().parameterTypes(); assert args.size() == argTypes.size(); for (int i = 0; i < args.size(); i++) { if (args.get(i) == l && isFloatingPointLike(argTypes.get(i))) { return true; } } return false; }
private boolean examineInvokeExpr(InvokeExpr e) { List<Value> args = e.getArgs(); List<Type> argTypes = e.getMethodRef().parameterTypes(); assert args.size() == argTypes.size(); for (int i = 0; i < args.size(); i++) { if (args.get(i) == l && isObject(argTypes.get(i))) { return true; } } // check for base SootMethodRef sm = e.getMethodRef(); if (!sm.isStatic()) { if (e instanceof AbstractInvokeExpr) { AbstractInstanceInvokeExpr aiiexpr = (AbstractInstanceInvokeExpr) e; Value b = aiiexpr.getBase(); if (b == l) { return true; } } } return false; }
private boolean examineInvokeExpr(InvokeExpr e) { List<Value> args = e.getArgs(); List<Type> argTypes = e.getMethodRef().parameterTypes(); assert args.size() == argTypes.size(); for (int i = 0; i < args.size(); i++) { if (args.get(i) == l && isObject(argTypes.get(i))) { return true; } } // check for base SootMethodRef sm = e.getMethodRef(); if (!sm.isStatic()) { if (e instanceof AbstractInvokeExpr) { AbstractInstanceInvokeExpr aiiexpr = (AbstractInstanceInvokeExpr) e; Value b = aiiexpr.getBase(); if (b == l) { return true; } } } return false; }
protected MutableDirectedGraph<EquivalentValue> getInvokeAbbreviatedInfoFlowGraph(InvokeExpr ie, SootMethod context) { // get the data flow graph for each possible target of ie, // then combine them conservatively and return the result. SootMethodRef methodRef = ie.getMethodRef(); return getMethodInfoFlowAnalysis(methodRef.resolve()).getMethodAbbreviatedInfoFlowGraph(); }
public void convertToBaf(JimpleToBafContext context, List<Unit> out) { InvokeExpr ie = getInvokeExpr(); context.setCurrentUnit(this); ((ConvertToBaf) ie).convertToBaf(context, out); if (!ie.getMethodRef().returnType().equals(VoidType.v())) { Unit u = Baf.v().newPopInst(ie.getMethodRef().returnType()); u.addAllTagsOf(this); out.add(u); } }
private static SootMethod getMethodSafely(InvokeExpr invokeExpr) { try { final SootMethod invokedMethod = invokeExpr.getMethod(); if (invokedMethod == null) { return null; } if (SootMethod.constructorName.equals(invokedMethod.getName()) || SootMethod.staticInitializerName.equals(invokedMethod.getName())) { logger.debug("Skipping wrapping method {} as it is constructor/initializer.", invokedMethod); return null; } final SootClass invokedMethodClass = invokedMethod.getDeclaringClass(); if (!invokedMethodClass.isLibraryClass()) { logger.debug("Skipping wrapping method {} as it is not library one.", invokedMethod); return null; } if (invokeExpr.getMethodRef().declaringClass().isInterface() && !invokedMethodClass.isInterface()) { logger.debug( "Skipping wrapping method {} as original code suppose to execute it on interface {}" + " but resolved code trying to execute it on class {}", invokedMethod, invokeExpr.getMethodRef().declaringClass(), invokedMethodClass); return null; } return invokedMethod; } catch (RuntimeException exception) { logger.debug("Cannot resolve method of InvokeExpr: " + invokeExpr.toString(), exception); return null; } }
private void changeUntypedConstantsInInvoke(InvokeExpr invokeExpr) { for (int i = 0; i < invokeExpr.getArgCount(); i++) { Value v = invokeExpr.getArg(i); if (!(v instanceof UntypedConstant)) { continue; } Type t = invokeExpr.getMethodRef().parameterType(i); UntypedConstant uc = (UntypedConstant) v; invokeExpr.setArg(i, uc.defineType(t)); } }
public void caseInvokeStmt(InvokeStmt s) { emitValue(s.getInvokeExpr()); Type returnType = ((InvokeExpr) s.getInvokeExpr()).getMethodRef().returnType(); if (!returnType.equals(VoidType.v())) { // Need to do some cleanup because this value is not used. if (sizeOfType(returnType) == 1) { emit("pop", -1); } else { emit("pop2", -2); } } }
protected void checkInvokeExpr(Body b, InvokeExpr ie, Stmt s) { if (ie instanceof InstanceInvokeExpr && ((InstanceInvokeExpr) ie).getBase().getType() instanceof ArrayType && ie.getMethodRef().name().equals("clone") && ie.getMethodRef().parameterTypes().size() == 0) { return; // the call is to the clone() method of an array type, which ? getExceptionSpec(ie.getMethodRef().declaringClass(), ie.getMethodRef().getSubSignature())
@Override public void validate(Body body, List<ValidationException> exception) { for (Unit u : body.getUnits()) { if (u instanceof Stmt) { Stmt stmt = (Stmt) u; if (stmt.containsInvokeExpr()) { InvokeExpr iexpr = stmt.getInvokeExpr(); SootMethodRef ref = iexpr.getMethodRef(); if (ref.name().contains("'") || ref.declaringClass().getName().contains("'")) { throw new ValidationException(stmt, "Escaped name in signature found"); } for (Type paramType : ref.parameterTypes()) { if (paramType.toString().contains("'")) { throw new ValidationException(stmt, "Escaped name in signature found"); } } } } } }
protected void setInvokeType(InvokeExpr invokeExpr) { for (int i = 0; i < invokeExpr.getArgCount(); i++) { Value v = invokeExpr.getArg(i); if (!(v instanceof Local)) { continue; } Type t = invokeExpr.getMethodRef().parameterType(i); DalvikTyper.v().setType(invokeExpr.getArgBox(i), t, true); } if (invokeExpr instanceof StaticInvokeExpr) { // nothing to do } else if (invokeExpr instanceof InstanceInvokeExpr) { InstanceInvokeExpr iie = (InstanceInvokeExpr) invokeExpr; DalvikTyper.v().setType(iie.getBaseBox(), RefType.v("java.lang.Object"), true); } else if (invokeExpr instanceof DynamicInvokeExpr) { DynamicInvokeExpr die = (DynamicInvokeExpr) invokeExpr; // ? } else { throw new RuntimeException("error: unhandled invoke expression: " + invokeExpr + " " + invokeExpr.getClass()); } }
public void outInvokeExpr(InvokeExpr ie) { // If this is within a definitionStmt of a local if (inDefinitionStmt && (definedLocal != null)) { // if its a new object being created if (ie instanceof NewInvokeExpr) { // System.out.println("new object being created retrieve the name"); RefType ref = ((NewInvokeExpr) ie).getBaseType(); String className = ref.getClassName(); debug("outInvokeExpr", "defined local is" + definedLocal); info.setObjectClassName(definedLocal, className); } else { SootMethodRef methodRef = ie.getMethodRef(); String name = methodRef.name(); // System.out.println(name); info.setMethodName(definedLocal, name); } } }
@Override protected void internalTransform(Body b, String phaseName, Map<String, String> options) { for (Iterator<Unit> unitIt = b.getUnits().snapshotIterator(); unitIt.hasNext();) { Unit u = unitIt.next(); if (u instanceof Stmt) { Stmt s = (Stmt) u; if (s.containsInvokeExpr()) { InvokeExpr iexpr = s.getInvokeExpr(); if (iexpr instanceof StaticInvokeExpr) { if (isClassLoaded(iexpr.getMethodRef().declaringClass())) { SootMethod target = Scene.v().grabMethod(iexpr.getMethodRef().getSignature()); if (target != null && !target.isStatic()) { if (canBeMadeStatic(target)) { // Remove the this-assignment to prevent // 'this-assignment in a static method!' exception target.getActiveBody().getUnits().remove(target.getActiveBody().getThisUnit()); target.setModifiers(target.getModifiers() | Modifier.STATIC); logger.warn(target.getName() + " changed into a static method"); } } } } } } } }
private void handleInvokeExpr(InvokeExpr ie, Stmt stmt) { SootMethodRef m = ie.getMethodRef(); if (ie instanceof InstanceInvokeExpr) { InstanceInvokeExpr iie = (InstanceInvokeExpr) ie; iie.setBase(this.uv.visit(iie.getBase(), m.declaringClass().getType(), stmt)); } for (int i = 0; i < ie.getArgCount(); i++) { ie.setArg(i, this.uv.visit(ie.getArg(i), m.parameterType(i), stmt)); } }
SootMethodRef methodRef = ie.getMethodRef(); String subSig = methodRef.resolve().getSubSignature(); CallGraph cg = Scene.v().getCallGraph();
Stmt stmt = (Stmt) u; if (stmt.containsInvokeExpr()) { SootMethodRef called = stmt.getInvokeExpr().getMethodRef(); InvokeExpr iexpr = stmt.getInvokeExpr();
private void handleInvokeExpr(InvokeExpr ie) { if (!uses) { return; } // Handle the parameters SootMethodRef method = ie.getMethodRef(); for (int i = 0; i < ie.getArgCount(); i++) { if (ie.getArg(i) instanceof Local) { Local local = (Local) ie.getArg(i); if (local.getType() instanceof IntegerType) { TypeVariable localType = resolver.typeVariable(local); localType.addParent(resolver.typeVariable(method.parameterType(i))); } } } if (ie instanceof DynamicInvokeExpr) { DynamicInvokeExpr die = (DynamicInvokeExpr) ie; SootMethodRef bootstrapMethod = die.getBootstrapMethodRef(); for (int i = 0; i < die.getBootstrapArgCount(); i++) { if (die.getBootstrapArg(i) instanceof Local) { Local local = (Local) die.getBootstrapArg(i); if (local.getType() instanceof IntegerType) { TypeVariable localType = resolver.typeVariable(local); localType.addParent(resolver.typeVariable(bootstrapMethod.parameterType(i))); } } } } }
SootMethodRef method = ie.getMethodRef(); for (int i = 0; i < ie.getArgCount(); i++) { if (ie.getArg(i) instanceof Local) {
SootMethodRef method = v.getMethodRef(); SootMethod m = method.resolve();
private void handleInvokeExpr(InvokeExpr ie, Stmt invokestmt) { SootMethodRef method = ie.getMethodRef(); for (int i = 0; i < ie.getArgCount(); i++) { if (ie.getArg(i) instanceof Local) {