public static int getDexAccessFlags(SootMethod m) { int dexAccessFlags = m.getModifiers(); // dex constructor flag is not included in the Soot modifiers, so add it if // necessary if (m.isConstructor() || m.getName().equals(SootMethod.staticInitializerName)) { dexAccessFlags |= Modifier.CONSTRUCTOR; } // add declared_synchronized for dex if synchronized if (m.isSynchronized()) { dexAccessFlags |= Modifier.DECLARED_SYNCHRONIZED; // even remove synchronized if not native, since only allowed there if (!m.isNative()) { dexAccessFlags &= ~Modifier.SYNCHRONIZED; } } return dexAccessFlags; }
if (curStmt.containsInvokeExpr()) { InvokeExpr expr = curStmt.getInvokeExpr(); if (expr.getMethod().isConstructor()) { if (!(expr instanceof SpecialInvokeExpr)) { exception.add(new ValidationException(curStmt, "<init> method calls may only be used with specialinvoke."));
if (wrappedNode instanceof LocalVarNode && ((LocalVarNode) wrappedNode).isThisPtr()) { SootMethod func = ((LocalVarNode) wrappedNode).getMethod(); if (!func.isConstructor()) {
if (wrappedNode instanceof LocalVarNode && ((LocalVarNode) wrappedNode).isThisPtr()) { SootMethod func = ((LocalVarNode) wrappedNode).getMethod(); if (!func.isConstructor()) {
if (wrappedNode instanceof LocalVarNode && ((LocalVarNode) wrappedNode).isThisPtr()) { SootMethod func = ((LocalVarNode) wrappedNode).getMethod(); if (!func.isConstructor()) {
continue; if (n.isStatic() || n.isConstructor() || n.isStaticInitializer() || !n.isConcrete()) { continue;
if (m.isConstructor()) { final Body body = m.retrieveActiveBody(); for (Unit u : body.getUnits()) {
|| (sm.isConstructor() && (rOp instanceof ParameterRef)) || (rOp instanceof Constant); if (writtenFields.contains(f) || !nonVariableAssign) {
/** * Checks whether the given method body is a stub implementation and can safely * be overwritten * * @param body * The body to check * @return True if the given method body is a stub implementation, otherwise * false */ private boolean isStubImplementation(Body body) { for (Unit u : body.getUnits()) { Stmt stmt = (Stmt) u; if (stmt.containsInvokeExpr()) { InvokeExpr iexpr = stmt.getInvokeExpr(); SootMethod targetMethod = iexpr.getMethod(); if (targetMethod.isConstructor() && targetMethod.getDeclaringClass().getName().equals("java.lang.RuntimeException")) if (iexpr.getArgCount() > 0 && iexpr.getArg(0).equals(stubConst)) return true; } } return false; }
if (sm.isConstructor()) { if (reachableMethods.contains(sm)) { hasConstructor = true;
protected List<Unit> createNewException(Body b, Local exLocal, SootClass exc, Host createdFrom) { List<Unit> result = new LinkedList<Unit>(); /* * generate l := new Exception constructor call throw l */ Local l = exLocal; // l = new Exception Unit newException = assignStmtFor(l, Jimple.v().newNewExpr(RefType.v(exc)), createdFrom); result.add(newException); // constructor call boolean foundConstructor = false; for (SootMethod sm : exc.getMethods()) { if (sm.isConstructor() && sm.getParameterCount() == 0) { // This is the constructor we are looking for. foundConstructor = true; result.add(invokeStmtFor(Jimple.v().newSpecialInvokeExpr(l, sm.makeRef()), createdFrom)); break; } } Verify.verify(foundConstructor, "Don't try to call a constructor on an abstract class or interface!"); return result; }
/** * Helper method to create a push of all field locals. * This method should only be used at the very end of a constructor. */ private void pushAllFields() { SootMethod m = SootTranslationHelpers.v().getCurrentMethod(); if (!m.isConstructor() || m.isStatic() || !m.isConcrete()) { return; } SourceLocation loc = this.statementSwitch.getCurrentLoc(); Variable thisLocal = this.statementSwitch.getMethodInfo().lookupLocalVariable(m.getActiveBody().getThisLocal()); ClassVariable classVar = ((ReferenceType) thisLocal.getType()).getClassVariable(); List<Variable> vars = new LinkedList<Variable>(); for (SootField sf : SootTranslationHelpers.findNonStaticFieldsRecursively(m.getDeclaringClass())) { vars.add(lookupFieldLocal(thisLocal, sf)); } List<Expression> packedVars = new LinkedList<Expression>(); for (int i = 0; i < vars.size(); i++) { packedVars.add(new IdentifierExpression(loc, vars.get(i))); } PushStatement push = new PushStatement(loc, classVar, new IdentifierExpression(loc, thisLocal), packedVars); this.statementSwitch.push(push); }
private boolean pullAt(Unit u, FieldRef fr) { SootMethod m = SootTranslationHelpers.v().getCurrentMethod(); if (fr instanceof InstanceFieldRef) { InstanceFieldRef ifr = (InstanceFieldRef) fr; // in constructor never pull 'this'... if (m.isConstructor() && ifr.getBase().equals(m.getActiveBody().getThisLocal())) { // ...except after a method call UnitGraph graph = new CompleteUnitGraph(m.getActiveBody()); if (methodCallAfterLastFieldRef(u, graph, m.getActiveBody().getThisLocal())) { return true; } return false; } } else if (fr instanceof StaticFieldRef) { // in static initializer never pull static field if (m.isStaticInitializer()) return false; } return true; }
if (parentClass.getName().startsWith("android.")) for (SootMethod sm : parentClass.getMethods()) if (!sm.isConstructor()) systemMethods.put(sm.getSubSignature(), sm); if (!sm.isConstructor()) { SootMethod parentMethod = systemMethods.get(sm.getSubSignature()); if (parentMethod != null)
if (targetMethod.isConstructor() || targetMethod.isStaticInitializer()) return false;
Verify.verifyNotNull(memoryModel); outVarTypes.add(memoryModel.lookupType(m.getReturnType())); } else if (m.isConstructor()) {
else if (methodToInvoke.isConcrete() && !methodToInvoke.isConstructor()) {
if (SystemClassHandler.isClassInSystemPackage(parentClass.getName())) for (SootMethod sm : parentClass.getMethods()) if (!sm.isConstructor()) systemMethods.put(sm.getSubSignature(), sm);
if (sm.isConstructor()) { int i=0; for (SootField sf : SootTranslationHelpers.findNonStaticFieldsRecursively(sm.getDeclaringClass())) {
if (method.isConstructor() || method.isStaticInitializer()) return false;