[Soot-list] patch to allow adding application class during BodyTransformer

Phil Pratt-Szeliga pcpratts at syr.edu
Thu Apr 12 13:18:03 EDT 2012


Hi,

Attached is a patch to allow adding an application class during a
BodyTransformer. Pasted below is my test code. Without this patch
there is a concurrent modification exception, after the random classes
are written to the filesystem.

///////////////////////////////////////////////////////////

import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
import soot.*;

public class KernelTransform extends BodyTransformer {

  @Override
  protected void internalTransform(Body body, String string, Map map) {
    String name = randomClassName();
    SootClass new_class = new SootClass(name);
    Scene.v().addClass(new_class);
    new_class.setApplicationClass();
  }

  private String randomClassName(){
    String ret = UUID.randomUUID().toString();
    ret = ret.replaceAll("-", "");
    ret = "RandomClass"+ret;
    return ret;
  }
}

//////////////////////////////////////////////////////

Phil Pratt-Szeliga
Syracuse University
-------------- next part --------------
A non-text attachment was scrubbed...
Name: add_application_class.patch
Type: application/octet-stream
Size: 864 bytes
Desc: not available
Url : http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20120412/aa11901d/attachment.obj 


More information about the Soot-list mailing list