[Soot-list] What is the difference between getMethod() and getMethodRef()?
Patrick Lam
plam at sable.mcgill.ca
Fri Jan 25 17:12:58 EST 2013
On 01/25/13 17:03, Marc-Andre Laverdiere-Papineau wrote:
> Hello,
>
> I have been plagued with weird exceptions like this:
>
> Exception in thread "main"
> soot.SootMethodRefImpl$ClassResolutionFailedException: Class
> javax.servlet.ServletContext doesn't have method getContextPath([]) :
> java.lang.String; failed to resolve in superclasses and
> interfacesLooking in javax.servlet.ServletContext which has methods
> [<javax.servlet.ServletContext: javax.servlet.ServletContext
> getContext(java.lang.String)>,<javax.servlet.ServletContext: int
> ...<javax.servlet.ServletContext: javax.servlet.Servlet
> getServlet(java.lang.String)>,<javax.servlet.ServletContext:
> java.util.Enumeration getServlets()>,<javax.servlet.ServletContext:
> java.util.Enumeration getServletNames()>,
> ...
> <javax.servlet.ServletContext: void
> log(java.lang.String,java.lang.Throwable)>,
> <javax.servlet.ServletContext: java.lang.String
> getRealPath(java.lang.String)>,<javax.servlet.ServletContext:
> java.lang.String getServerInfo()>,<javax.servlet.ServletContext:
> ...<java.lang.Object: void wait()>,<java.lang.Object: void finalize()>,
> <java.lang.Object: void<clinit>()>]
>
> at soot.SootMethodRefImpl.resolve(SootMethodRefImpl.java:179)
> at soot.SootMethodRefImpl.resolve(SootMethodRefImpl.java:105)
> at
> soot.jimple.internal.AbstractInvokeExpr.getMethod(AbstractInvokeExpr.java:54)
> at ...
>
> It happens if I have something like this:
> ((DefinitionStmt)u).getInvokeExpr().getMethod()...
>
> However, changing it to getMethodRef() won't break - why??? (Sidenote: I
> am running without exclusions)
Well, if you are just getting the MethodRef, you don't need the method
to be resolved. It's analogous to requesting a pointer to the method
without dereferencing it.
Taking a broader view, it seems like you have weirdness in your input
files where you have references to nonexistent methods. Do you need to
do anything with all of the methods that you're referencing? If not,
getMethodRef() should be fine.
pat
More information about the Soot-list
mailing list