public void setMainClass(SootClass m) { mainClass = m; if (!m.declaresMethod(getSubSigNumberer().findOrAdd("void main(java.lang.String[])"))) { throw new RuntimeException("Main-class has no main method!"); } }
/** * Does this class declare a method with the given subsignature? */ public boolean declaresMethod(String subsignature) { checkLevel(SIGNATURES); NumberedString numberedString = Scene.v().getSubSigNumberer().find(subsignature); return numberedString == null ? false : declaresMethod(numberedString); }
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(); } }
if (currentClass.declaresMethod(signature)) { IterableSet otherMethods = methodMapping.get(startingMethod); if (otherMethods == null) {
/** * @ast method * @aspect EmitJimple * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/JimpleBackend/EmitJimple.jrag:145 */ public void jimplify1phase2() { if (needsClinit() && !getSootClassDecl().declaresMethod("<clinit>", new ArrayList())) { clinit = Scene.v().makeSootMethod("<clinit>", new ArrayList(), soot.VoidType.v(), soot.Modifier.STATIC, new ArrayList()); getSootClassDecl().addMethod(clinit); } for (Iterator iter = nestedTypes().iterator(); iter.hasNext();) { TypeDecl typeDecl = (TypeDecl) iter.next(); typeDecl.jimplify1phase2(); } for (int i = 0; i < getNumBodyDecl(); i++) if (getBodyDecl(i).generate()) getBodyDecl(i).jimplify1phase2(); addAttributes(); }
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 void setMainClassFromOptions() { if (mainClass != null) { return; } if (Options.v().main_class() != null && Options.v().main_class().length() > 0) { setMainClass(getSootClass(Options.v().main_class())); } else { // try to infer a main class from the command line if none is given for (Iterator<String> classIter = Options.v().classes().iterator(); classIter.hasNext();) { SootClass c = getSootClass(classIter.next()); if (c.declaresMethod("main", Collections.<Type>singletonList(ArrayType.v(RefType.v("java.lang.String"), 1)), VoidType.v())) { logger.debug("No main class given. Inferred '" + c.getName() + "' as main class."); setMainClass(c); return; } } // try to infer a main class from the usual classpath if none is // given for (Iterator<SootClass> classIter = getApplicationClasses().iterator(); classIter.hasNext();) { SootClass c = classIter.next(); if (c.declaresMethod("main", Collections.<Type>singletonList(ArrayType.v(RefType.v("java.lang.String"), 1)), VoidType.v())) { logger.debug("No main class given. Inferred '" + c.getName() + "' as main class."); setMainClass(c); return; } } } }
if (!(parentClass.declaresMethod("<init>", argsTwoTypes))) {
if (sootClass.declaresMethod(maybeInline.getSubSignature())) {
/** * Loads a single method from a dex file * * @param method * The method to load * @param declaringClass * The class that declares the method to load * @param annotations * The worker object for handling annotations * @param dexMethodFactory * The factory method for creating dex methods */ protected void loadMethod(Method method, SootClass declaringClass, DexAnnotation annotations, DexMethod dexMethodFactory) { SootMethod sm = dexMethodFactory.makeSootMethod(method); if (declaringClass.declaresMethod(sm.getName(), sm.getParameterTypes(), sm.getReturnType())) { return; } declaringClass.addMethod(sm); annotations.handleMethodAnnotation(sm, method); }
if (runtime.declaresMethod("void <init>(java.lang.String)")) { SootMethod sootMethod = runtime.getMethod("void <init>(java.lang.String)"); SootMethodRef methodRef = sootMethod.makeRef();
sootMethod.setSource(mSrc); if (!addToClass.declaresMethod(methodName, paramTypes, methodRetType)) { addToClass.addMethod(sootMethod); sootMethod.addTag(new soot.tagkit.SyntheticTag());
/** * @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(); }
if (randomClass.declaresMethod(methodNewName, smParamTypes)) { int rtmp = Rand.getInt(classCount + 7); if (rtmp >= classCount) {
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);
while (target.getDeclaringClass().declaresMethod(newName, newParameterTypes, target.getReturnType())) { newName = newName + "_static";
sootMethod.setSource(assertMSrc); if (!addToClass.declaresMethod(methodName, paramTypes, methodRetType)) { addToClass.addMethod(sootMethod); sootMethod.addTag(new soot.tagkit.SyntheticTag()); sootMethod.setSource(mSrc); if (!sootClass.declaresMethod(methodName, paramTypes, methodRetType)) { sootClass.addMethod(sootMethod); } else {
&& smr.getSubSignature().getString().startsWith("void " + constructorName)) { SootMethod newSuperInit; if (!mediatingClass.declaresMethod(constructorName, smr.parameterTypes())) { List<Type> paramTypes = smr.parameterTypes(); newSuperInit = Scene.v().makeSootMethod(constructorName, paramTypes, smr.returnType());
if (!sootClass.declaresMethod("<clinit>", new ArrayList(), soot.VoidType.v())) { clinitMethod = Scene.v().makeSootMethod("<clinit>", new ArrayList(), soot.VoidType.v(), soot.Modifier.STATIC, new ArrayList<SootClass>());
JimpleBody clinitBody = null; Stmt firstStmt = null; boolean addingNewClinit = !lockClass.declaresMethod("void <clinit>()"); if (addingNewClinit) { clinitMethod