public SootMethod getMethod(String subsignature) { checkLevel(SIGNATURES); NumberedString numberedString = Scene.v().getSubSigNumberer().find(subsignature); if (numberedString == null) { throw new RuntimeException("No method " + subsignature + " in class " + getName()); } return getMethod(numberedString); }
body.getLocals().add(bool); final SootMethod booleanWrapperConstructor = booleanWrapperRefType.getSootClass().getMethod("void <init>(boolean)"); units.addFirst(Jimple.v().newAssignStmt(Jimple.v().newStaticFieldRef(field.makeRef()), bool)); units.addFirst(Jimple.v().newInvokeStmt(
public Wrapper() { PrimType[] tmp = { BooleanType.v(), ByteType.v(), CharType.v(), DoubleType.v(), FloatType.v(), IntType.v(), LongType.v(), ShortType.v() }; wrapperTypes = new HashMap<>(); valueOf = new HashMap<>(); primitiveValue = new HashMap<>(); for (PrimType primType : tmp) { RefType wrapperType = primType.boxedType(); String cn = wrapperType.getClassName(); wrapperTypes.put(wrapperType, primType); String valueOfMethodSignature = cn + " valueOf(" + primType.toString() + ")"; SootMethod valueOfMethod = wrapperType.getSootClass().getMethod(valueOfMethodSignature); valueOf.put(primType, valueOfMethod); String primitiveValueMethodSignature = primType.toString() + " " + primType.toString() + "Value()"; SootMethod primitiveValueMethod = wrapperType.getSootClass().getMethod(primitiveValueMethodSignature); primitiveValue.put(wrapperType, primitiveValueMethod); } wrapperTypes = Collections.unmodifiableMap(wrapperTypes); valueOf = Collections.unmodifiableMap(valueOf); primitiveValue = Collections.unmodifiableMap(primitiveValue); }
public static void main(String[] args) { // assumes 2 args: Class + Method Scene.v().loadClassAndSupport(args[0]); SootClass sc = Scene.v().getSootClass(args[0]); SootMethod sm = sc.getMethod(args[1]); Body b = sm.retrieveActiveBody(); CompleteBlockGraph cfg = new CompleteBlockGraph(b); System.out.println(cfg); BlockGraphConverter.addStartStopNodesTo(cfg); System.out.println(cfg); BlockGraphConverter.reverse(cfg); System.out.println(cfg); }
private Optional<SootMethod> findAccessibleInSuperClassesBySubSig(SootClass base, String subSig) { Hierarchy hierarchy = Scene.v().getActiveHierarchy(); for (SootClass superClass : hierarchy.getSuperclassesOfIncluding(base.getSuperclass())) { if (superClass.isLibraryClass() && superClass.declaresMethod(subSig)) { SootMethod method = superClass.getMethod(subSig); if (hierarchy.isVisible(base, method)) { return Optional.of(method); } } } return Optional.empty(); } }
otherMethods.add(currentClass.getMethod(signature));
public static SootMethod getMainMethod() { return Scene.v().getMainClass().getMethod(Scene.v().getSubSigNumberer().findOrAdd("void main(java.lang.String[])")); }
/** * @apilevel internal */ private SootMethod sootMethod_compute() { ArrayList list = new ArrayList(); for (int i = 0; i < getNumParameter(); i++) list.add(getParameter(i).type().getSootType()); if (hostType().isArrayDecl()) return typeObject().getSootClassDecl().getMethod(name(), list, type().getSootType()); return hostType().getSootClassDecl().getMethod(name(), list, type().getSootType()); }
public void staticBlockInlining(SootClass sootClass) { this.sootClass = sootClass; // retrieve the clinit method if any for sootClass // the clinit method gets converted into the static block which could initialize the final variable if (!sootClass.declaresMethod("void <clinit>()")) { // System.out.println("no clinit"); return; } SootMethod clinit = sootClass.getMethod("void <clinit>()"); // System.out.println(clinit); // retireve the active body if (!clinit.hasActiveBody()) { throw new RuntimeException("method " + clinit.getName() + " has no active body!"); } Body clinitBody = clinit.getActiveBody(); Chain units = ((DavaBody) clinitBody).getUnits(); if (units.size() != 1) { throw new RuntimeException("DavaBody AST doesn't have single root."); } ASTNode AST = (ASTNode) units.getFirst(); if (!(AST instanceof ASTMethodNode)) { throw new RuntimeException("Starting node of DavaBody AST is not an ASTMethodNode"); } // running methodCallFinder on the Clinit method AST.apply(new MethodCallFinder(this)); }
public static void main(String[] args) { // assumes 2 args: Class + Method Scene.v().loadClassAndSupport(args[0]); SootClass sc = Scene.v().getSootClass(args[0]); SootMethod sm = sc.getMethod(args[1]); Body b = sm.retrieveActiveBody(); ShimpleBody sb = Shimple.v().newBody(b); CompleteBlockGraph cfg = new CompleteBlockGraph(sb); ValueGraph vg = new ValueGraph(cfg); System.out.println(vg); }
public static void main(String[] args) { // assumes 2 args: Class + Method Scene.v().loadClassAndSupport(args[0]); SootClass sc = Scene.v().getSootClass(args[0]); SootMethod sm = sc.getMethod(args[1]); Body b = sm.retrieveActiveBody(); ShimpleBody sb = Shimple.v().newBody(b); CompleteBlockGraph cfg = new CompleteBlockGraph(sb); SimpleGlobalValueNumberer sgvn = new SimpleGlobalValueNumberer(cfg); System.out.println(sgvn); }
SootMethod superConstructor = parentClass.getMethod("<init>", argsTwoTypes);
/** * @apilevel internal */ private SootMethod sootMethod_compute() { ArrayList list = new ArrayList(); // this$0 TypeDecl typeDecl = hostType(); if (typeDecl.needsEnclosing()) list.add(typeDecl.enclosingType().getSootType()); if (typeDecl.needsSuperEnclosing()) { TypeDecl superClass = ((ClassDecl) typeDecl).superclass(); list.add(superClass.enclosingType().getSootType()); } // args for (int i = 0; i < getNumParameter(); i++) list.add(getParameter(i).type().getSootType()); return hostType().getSootClassDecl().getMethod("<init>", list, soot.VoidType.v()); }
SootMethod sootMethod = runtime.getMethod("void <init>(java.lang.String)"); SootMethodRef methodRef = sootMethod.makeRef(); RefType myRefType = RefType.v(runtime);
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); } }
/** * @ast method * @aspect EmitJimple * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/JimpleBackend/EmitJimple.jrag:210 */ public void jimplify1phase2() { String name = name(); ArrayList parameters = new ArrayList(); ArrayList paramnames = new ArrayList(); for (int i = 0; i < getNumParameter(); i++) { parameters.add(getParameter(i).type().getSootType()); paramnames.add(getParameter(i).name()); } soot.Type returnType = type().getSootType(); int modifiers = sootTypeModifiers(); ArrayList throwtypes = new ArrayList(); for (int i = 0; i < getNumException(); i++) throwtypes.add(getException(i).type().getSootClassDecl()); String signature = SootMethod.getSubSignature(name, parameters, returnType); if (!hostType().getSootClassDecl().declaresMethod(signature)) { SootMethod m = Scene.v().makeSootMethod(name, parameters, returnType, modifiers, throwtypes); hostType().getSootClassDecl().addMethod(m); m.addTag(new soot.tagkit.ParamNamesTag(paramnames)); sootMethod = m; } else { sootMethod = hostType().getSootClassDecl().getMethod(signature); } addAttributes(); }
sootMethod = m; } else { sootMethod = hostType().getSootClassDecl().getMethod(signature);
.getMethod("<init>", Collections.<Type>singletonList(RefType.v("java.lang.String"))).makeRef(); SpecialInvokeExpr constructorInvokeExpr = Jimple.v().newSpecialInvokeExpr(exceptionLocal, cref, StringConstant.v(guard.message)); .getSootClass("java.lang.Throwable").getMethod("printStackTrace", Collections.<Type>emptyList()).makeRef()); InvokeStmt printStackTraceStmt = Jimple.v().newInvokeStmt(printStackTraceExpr); body.getUnits().insertAfter(printStackTraceStmt, initStmt);
sootClass.addMethod(sootMethod); } else { ((soot.javaToJimple.PolyglotMethodSource) sootClass.getMethod(methodName, paramTypes, methodRetType).getSource()) .hasAssert(true);