South: reloading the class after changing the source file

I am writing IntelliJ-Plugin to analyze the code of a Java program. Thus, I use Soot to record static analyzes. Each time a user launches an analysis action of my plugin, I accept the current VirtualFilecurrent context as follows:

FileEditorManager manager = FileEditorManager.getInstance(e.getProject());
VirtualFile files[] = manager.getSelectedFiles();
toAnalyse = files[0]; [...]

When I check the contents of this file, all changes are applied. After that, I load the class that I want to analyze in the Site.

String dir =  toAnalyse.getParent().getPath() ;
Options.v().setPhaseOption("jb", "use-original-names");
Options.v().set_soot_classpath( System.getProperty("java.home")+";"+ dir);
c = Scene.v().loadClassAndSupport(name);
/*no analyse c*/

This works great for me. But now to my problem: If I change sth. in the test instance of my plugin and run the same analysis again, nothing changes.

What have i tried so far?

I set the following options :

Options.v().set_dump_body( Arrays.asList("jb"));
Options.v().set_dump_cfg( Arrays.asList("jb"));
Options.v().set_allow_phantom_refs(true);
Options.v().set_whole_program(true);

I also deleted all classes manually

like this:

Chain<SootClass> classes = Scene.v().getClasses();
Stack<SootClass> stack = new Stack<>();
for(SootClass s : classes)
    stack.push(s);
while(!stack.empty())
    Scene.v().removeClass(stack.pop());

and started the program again.

+6
1

.

SootClass c = Scene.v().loadClassAndSupport(name);
// ...
c.setResolvingLevel(0);
G.reset();

G.reset() singleton. , .

public static Scene v() {
    return G.v().soot_Scene();
}

this.instance_soot_Scene null G.reset().

:

public Scene soot_Scene() {
    if(this.instance_soot_Scene == null) {
        synchronized(this) {
            if(this.instance_soot_Scene == null) {
                this.instance_soot_Scene = new Scene(this.g);
            }
        }
    }

    return this.instance_soot_Scene;
}

.

+5

All Articles