[Soot-list] SootClass.getMethodByName

Eugen Zalinescu eugen.zalinescu at gmail.com
Tue Jan 12 07:54:01 EST 2016


Hi Steven,

Here are more details. Now I've also localized the call where the
change in behavior occurs.

I'm doing an analysis (using ForwardFlowAnalysis) of a Java class, and
the 'main' method looks something like this:

SootClass c = Scene.v().loadClassAndSupport("securibench.micro.basic.Basic30");
c.setApplicationClass();
SootMethod m = c.getMethodByName("doGet")
Body b = m.retrieveActiveBody();
ExceptionalUnitGraph g = new ExceptionalUnitGraph(b);
// build a ForwardFlowAnalysis object from g

Now, in the flowThrough method, for the unit d that is 'r3 =
interfaceinvoke r1.<javax.servlet.http.HttpServletRequest:
java.lang.String getParameter(java.lang.String)>("name");' the code
looks like this:

Main.testExists(); // here method not found
SootMethod m = ((InvokeExpr)d).getMethod();
Main.testExists(); // here method found

where testExists in Main is:
static void testExists() {
        try {
            SootClass c =
Scene.v().getSootClass("javax.servlet.http.HttpServletRequest");
            c.getMethodByName("getParameter");
            System.out.println("IT WORKS!!!");
        } catch (RuntimeException e) {
            System.out.println("It does NOT work.");
        }
    }

So it seems that the call to InvokeExpr.getMethod() makes the
difference. My main question is why is this, and my second question
would be how to make Soot find the 'getParameter' method before
starting the analysis.

Thanks,
Eugen







On Tue, Jan 12, 2016 at 12:05 PM, Steven Arzt <Steven.Arzt at cased.de> wrote:
> Hi Eugen,
>
> Without further details, it's hard to estimate what's happening there. Maybe
> your first calls happens at a point in time when the class has not been
> loaded yet. If you are using multiple threads in your code, you might be
> trying to access  the method while Soot's resolver is still loading the
> bodies.
>
> Best regards,
>   Steven
>
> -----Ursprüngliche Nachricht-----
> Von: soot-list-bounces at CS.McGill.CA [mailto:soot-list-bounces at CS.McGill.CA]
> Im Auftrag von Eugen Zalinescu
> Gesendet: Montag, 11. Januar 2016 16:42
> An: soot-list at CS.McGill.CA
> Betreff: [Soot-list] SootClass.getMethodByName
>
> Hello,
>
> I get the following behavior. At some point in the program calling the
> method SootClass.getMethodByName raises an exception, concretely:
>   Exception in thread "main" java.lang.RuntimeException: No method
> getParameter in class   javax.servlet.http.HttpServletRequest
> while calling the same method on the same SootClass object later during the
> analysis, with the same arguments returns the looked for method.
>
> This seems strange to me, but maybe someone has an explanation for it?
>
> Thanks,
> Eugen
> _______________________________________________
> 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