if (meths[i].getName().equals(methodname))
visitJavaMethod(repo.loadClass(classname), meths[i]);
}
- public static void main(String[] s) throws Exception {
+ public static void main(String[] args) throws Exception {
int start = 1;
- repo = SyntheticRepository.getInstance(new ClassPath(s[0]));
+ repo = SyntheticRepository.getInstance(new ClassPath(args[0]));
NanoGoat bcp = new NanoGoat();
- for(int i=start; i<s.length; i++) {
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+ for(String s = br.readLine(); s != null; s = br.readLine()) {
+ s = s.trim();
+ if (s.length() == 0) continue;
try {
- if (s[i].endsWith(".class")) {
- bcp.visitJavaClass(repo.loadClass(s[i].substring(0, s[i].length() - 6)));
+ if (s.endsWith("$")) s = s.substring(0, s.length() - 1);
+ if (s.endsWith(".class")) {
+ bcp.visitJavaClass(repo.loadClass(s.substring(0, s.length() - 6)));
} else {
- JavaClass cl = repo.loadClass(s[i].substring(0, s[i].lastIndexOf('.')));;
+ JavaClass cl = repo.loadClass(s.substring(0, s.lastIndexOf('.')));;
bcp.visitJavaClass(cl);
- bcp.loadMethod(s[i]);
+ bcp.loadMethod(s);
Field[] fields = cl.getFields();
for(int j=0; j<fields.length; j++) {
- if (fields[j].getName().equals(s[i].substring(s[i].lastIndexOf('.') + 1)))
+ if (fields[j].getName().equals(s.substring(s.lastIndexOf('.') + 1)))
bcp.visitJavaField(fields[j], cl);
}
}
} catch (Exception e) {
- System.out.println("WARNING: couldn't load class for " + s[i]);
+ System.out.println("WARNING: couldn't load class for " + s);
e.printStackTrace();
}
}
System.out.println();
System.out.println("Dumping...");
- ZipFile zf = new ZipFile(s[0]);
- ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(s[0] + ".tmp"));
+ ZipFile zf = new ZipFile(args[0]);
+ ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(args[0] + ".tmp"));
Enumeration e = zf.entries();
while(e.hasMoreElements()) {
ZipEntry ze = ((ZipEntry)e.nextElement());
}
zos.close();
zf.close();
- new File(s[0] + ".tmp").renameTo(new File(s[0] + ".pruned"));
+ new File(args[0] + ".tmp").renameTo(new File(args[0] + ".pruned"));
}
public static void dump(JavaClass clazz, ZipOutputStream zos) throws Exception {