StringTokenizer st = new StringTokenizer(extDirs, File.pathSeparatorChar+"");
while(st.hasMoreTokens()) {
String goo = st.nextToken();
- System.out.println("goo " + goo);
File f = new File(goo);
if (!f.exists() || !f.isDirectory()) continue;
String[] jars = f.list();
// Set up the Arena zero-arg constructor
SootClass arena = getArenaForGladiator(sc);
- SootMethod arenaInitMethod = arena.getMethod("<init>", new LinkedList());
+ SootMethod arenaInitMethod = null;
+ for(Iterator it = arena.getMethods().iterator(); it.hasNext();) {
+ SootMethod m = (SootMethod)it.next();
+ if (m.getName().equals("<init>")) {
+ if (arenaInitMethod != null) throw new Error("class " + arena.getName() + " has two constructors");
+ arenaInitMethod = m;
+ }
+ }
JimpleBody arenaInitBody = (JimpleBody)arenaInitMethod.getActiveBody();
SootField maxField = new SootField(getGladiatorName(sc) + "$$max", IntType.v());
boolean doremove = true;
Body mincBody = m.getActiveBody();
if (implementsGladiator(m.getDeclaringClass()) && m.getName().equals("<init>")) {
+ System.out.println("processing ctor " + sc.getName() + "." + m.getSignature());
doremove = false;
SootClass c = m.getDeclaringClass();
- String name = /*c.getShortName().substring(c.getShortName().lastIndexOf('$')+1) + */"$init";
+ String name = "$init";
List li = m.getParameterTypes();
c.removeMethod(m);
SootMethod nm = new SootMethod(name, li, implementsGladiator(m.getReturnType()) ? IntType.v() : m.getReturnType());
nm.setActiveBody(bod);
m = nm;
mincBody = bod;
- mincBody.getUnits().remove(((JimpleBody)mincBody).getFirstNonIdentityStmt());
- mincBody.getUnits().remove(((JimpleBody)mincBody).getFirstNonIdentityStmt());
+
+ for(Iterator it2 = mincBody.getUnits().snapshotIterator(); it2.hasNext(); ) {
+ Unit u = (Unit)it2.next();
+ if (u instanceof DefinitionStmt) {
+ DefinitionStmt ds = (DefinitionStmt)u;
+ if (ds.getLeftOp() instanceof ThisRef)
+ mincBody.getUnits().remove(u);
+ else if (ds.getLeftOp() instanceof FieldRef) {
+ if (((FieldRef)ds.getLeftOp()).getFieldRef().name().endsWith("this$0"))
+ mincBody.getUnits().remove(u);
+ }
+ } else if (u instanceof InvokeStmt) {
+ InvokeExpr ie = ((InvokeStmt)u).getInvokeExpr();
+ SootMethod meth = ie.getMethod();
+ System.out.println(meth.getName());
+ if (meth.getDeclaringClass().getName().equals("java.lang.Object") && meth.getName().equals("<init>"))
+ mincBody.getUnits().remove(u);
+ }
+ }
+
} else {
System.out.println("examining " + sc.getName() + "." + m.getSignature());
m.retrieveActiveBody();
List list = new LinkedList();
list.addAll(m.getParameterTypes());
list.add(IntType.v());
- for(Iterator i = list.iterator(); i.hasNext();) System.out.println(i.next());
SootMethod m2 = new SootMethod(name, list, m.getReturnType());
getArenaForGladiator(sc).addMethod(m2);
}
*/
if (vb.getValue() instanceof ThisRef) {
- System.out.println(s);
vb.setValue(loc);
}
}
body = b2;
}
Chain units = body.getUnits();
- System.out.println("processBody("+body.getMethod()+")");
for(Iterator it = body.getLocals().snapshotIterator(); it.hasNext();) {
Local l = (Local)it.next();
if (implementsGladiator(l.getType())) l.setType(IntType.v());
SootFieldRef fr = ifr.getFieldRef();
Type t = fr.type();
if (implementsGladiator(fr.declaringClass()) && fr.name().equals("this$0")) {
- System.out.println("******************");
vb.setValue(body.getThisLocal());
- System.out.println("s is " + s);
} else if (implementsGladiator(fr.declaringClass())) {
SootClass arena = getArenaForGladiator(fr.declaringClass());
InstanceFieldRef sfr = newIFR(body, getSliceForField(fr));