[Soot-list] How to change the return type of an method

Marc-André Laverdière marc-andre.laverdiere-papineau at polymtl.ca
Mon May 12 09:56:32 EDT 2014


Hallo Benedikt,

A few things.

1) If you want to change only one method, better use a SceneTransformer
instead of checking the whole program!
2) Changing a return type would have a lot of impact on a call graph.
I'd do that change before Spark runs (wjpp phase)
3) You need to clarify if you want to change the returned type from the
method for all invocations, which means changing the SootMethod object
(probably a bad idea), or if you want to transform the returned value
into something else because you want to do an optimization or somethin'.

Marc-André Laverdière-Papineau
Doctorant - PhD Candidate

On 05/12/2014 09:17 AM, Benedikt Lesch wrote:
> Hi,
> I want to change the return value of the filereader.readline() method.
> 
> all I have is the following
> 
> @Override
> protected void internalTransform(final Body b, String phaseName,
> @SuppressWarnings("rawtypes") Map options) {
> Iterator<Unit> iter = b.getUnits().snapshotIterator();
> while (iter.hasNext()) {
> Stmt s = (Stmt) iter.next();
> if (s.containsInvokeExpr()) {
> SootMethod method = s.getInvokeExpr().getMethod();
> String declaringClass =
> s.getInvokeExpr().getMethod().getDeclaringClass().getName();
> if(declaringClass.equals("java.io.BufferedReader") &&
> method.getName().equals("readLine")) {
> //change return value
> }
> }
> }
> }
> 
> can you please tell how to change the value from here
> 
> Thanks
> Benedikt
> 
> 
> _______________________________________________
> Soot-list mailing list
> Soot-list at CS.McGill.CA
> https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
> 


More information about the Soot-list mailing list