[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question about retrieveActiveBody()



In Soot 2.1.0 SootMethod looks (roughly) like this:

    public Body retrieveActiveBody() {
        if (declaringClass.isPhantomClass())
            throw new RuntimeException()
        if (!hasActiveBody()) {
            setActiveBody(this.getBodyFromMethodSource("jb"));
            ms = null;
        }
        return getActiveBody();
    }

    private Body getBodyFromMethodSource(String phaseName) {
        return ms.getBody(this, phaseName);
    }

    public void releaseActiveBody() {
        activeBody = null;
    }

So the following sequence causes a NullPointerException:

	method.retrieveActiveBody();
	method.releaseActiveBody();
	method.retrieveActiveBody();

because on the second call to retrieveActiveBody, ms is null.

My question is: why is "ms = null" in retrieveActiveBody()?

This is causing a problem in my application: since I'm using Soot as
a library, in order to not leak memory I need to invoke releaseActiveBody()
after analyzing each method. However, if I need to analyze that method
again later, the second call to retrieveActiveBody() generates a
NullPointerException. Instead, I'd rather that Soot re-read the method
from the classfile and re-generated the Jimple.

Would there be any problem by simply removing the "ms = null" line?

Or should I bail on this approach and just create a new ClassLoader
for each analysis "run" (and hope that whatever VM I'm running on
supports class unloading)?

Thanks,
-Archie

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com