newConstructor.setDeclaringClass(originalSootClass);
private void finalizeConstructor() { // set davaBody...totally redundant but have to do as this is checked by // toString of ASTMethodNode newASTConstructorMethod.setDavaBody(newConstructorDavaBody); newConstructorDavaBody.getUnits().clear(); newConstructorDavaBody.getUnits().addLast(newASTConstructorMethod); System.out.println("Setting declaring class of method" + newConstructor.getSubSignature()); newConstructor.setDeclaringClass(originalSootClass); }
private SootMethodRef makeMethodRef(String methodName, ArrayList args) { // make MethodRef for methodName SootMethod method = Scene.v().makeSootMethod(methodName, args, RefType.v("java.lang.Object")); // set the declaring class of new method to be the DavaSuperHandler // class method.setDeclaringClass(new SootClass("DavaSuperHandler")); return method.makeRef(); }
public synchronized SootMethod getOrAddMethod(SootMethod m) { checkLevel(SIGNATURES); if (m.isDeclared()) { throw new RuntimeException("already declared: " + m.getName()); } if (methodList == null) { methodList = new ArrayList<>(); subSigToMethods = new SmallNumberedMap<>(); } SootMethod old = subSigToMethods.get(m.getNumberedSubSignature()); if (old != null) { return old; } subSigToMethods.put(m.getNumberedSubSignature(), m); methodList.add(m); m.setDeclared(true); m.setDeclaringClass(this); return m; }
/** * Adds the given method to this class. */ public void addMethod(SootMethod m) { checkLevel(SIGNATURES); if (m.isDeclared()) { throw new RuntimeException("already declared: " + m.getName()); } /* * if(declaresMethod(m.getName(), m.getParameterTypes())) throw new RuntimeException("duplicate signature for: " + * m.getName()); */ if (methodList == null) { methodList = new ArrayList<>(); subSigToMethods = new SmallNumberedMap<>(); } if (subSigToMethods.get(m.getNumberedSubSignature()) != null) { throw new RuntimeException("Attempting to add method " + m.getSubSignature() + " to class " + this + ", but the class already has a method with that signature."); } subSigToMethods.put(m.getNumberedSubSignature(), m); methodList.add(m); m.setDeclared(true); m.setDeclaringClass(this); }
method.setDeclaringClass(sootClass); SootMethodRef getMethodRef = method.makeRef();
/** * Removes the given method from this class. */ public void removeMethod(SootMethod m) { checkLevel(SIGNATURES); if (!m.isDeclared() || m.getDeclaringClass() != this) { throw new RuntimeException("incorrect declarer for remove: " + m.getName()); } if (subSigToMethods.get(m.getNumberedSubSignature()) == null) { throw new RuntimeException("Attempt to remove method " + m.getSubSignature() + " which is not in class " + this); } subSigToMethods.put(m.getNumberedSubSignature(), null); methodList.remove(m); m.setDeclared(false); m.setDeclaringClass(null); Scene.v().getMethodNumberer().remove(m); }
tempMethod.setDeclaringClass(new SootClass("java.lang.Boolean")); tempMethod.setDeclaringClass(new SootClass("java.lang.Byte")); tempMethod.setDeclaringClass(new SootClass("java.lang.Character")); tempMethod.setDeclaringClass(new SootClass("java.lang.Double")); tempMethod.setDeclaringClass(new SootClass("java.lang.Float")); tempMethod.setDeclaringClass(new SootClass("java.lang.Integer")); tempMethod.setDeclaringClass(new SootClass("java.lang.Long")); tempMethod.setDeclaringClass(new SootClass("java.lang.Short"));
private void createSootPreInitMethod() { // get a unique name for the method String uniqueName = getUniqueName(); // NOTICE WE ARE DEFINING ARGS AS SAME AS THE ORIGINAL METHOD newSootPreInitMethod = Scene.v().makeSootMethod(uniqueName, argsOneTypes, (new SootClass("DavaSuperHandler")).getType()); // set the declaring class of new method to be the originalSootClass newSootPreInitMethod.setDeclaringClass(originalSootClass); // set method to private and static newSootPreInitMethod.setModifiers(soot.Modifier.PRIVATE | soot.Modifier.STATIC); // initalize a new DavaBody, notice this causes all DavaBody vars to be // null newPreInitDavaBody = Dava.v().newBody(newSootPreInitMethod); // setting params is really important if you want the args to have // proper names in the new method newPreInitDavaBody.set_ParamMap(originalPMap); // set as activeBody newSootPreInitMethod.setActiveBody(newPreInitDavaBody); }