added OptimizeCore
authoradam <adam@megacz.com>
Sat, 2 Jul 2005 09:02:48 +0000 (09:02 +0000)
committeradam <adam@megacz.com>
Sat, 2 Jul 2005 09:02:48 +0000 (09:02 +0000)
darcs-hash:20050702090248-5007d-8abbe2c3fb5f9a09fef662c0dd030cf18f6386a0.gz

src/org/ibex/core/OptimizeCore.java [new file with mode: 0644]

diff --git a/src/org/ibex/core/OptimizeCore.java b/src/org/ibex/core/OptimizeCore.java
new file mode 100644 (file)
index 0000000..226a0f9
--- /dev/null
@@ -0,0 +1,34 @@
+package org.ibex.core;
+import org.ibex.classgen.*;
+import java.io.*;
+import java.util.*;
+import java.util.zip.*;
+
+public class OptimizeCore {
+    public static void main(String[] s) throws Exception {
+        File outf = new File(s[0] + "-");
+        File inf = new File(s[0]);
+        ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outf));
+        ZipInputStream zis = new ZipInputStream(new FileInputStream(inf));
+        for(;;) {
+            ZipEntry ze = zis.getNextEntry();
+            if (ze==null) break;
+            out.putNextEntry(ze);
+            String name = ze.getName();
+            if (!name.endsWith(".class")) {
+                byte b[] = new byte[1024];
+                for(;;) {
+                    int numread = zis.read(b, 0, b.length);
+                    if (numread==-1) break;
+                    out.write(b, 0, numread);
+                }
+                continue;
+            }
+            System.out.println("updating " + name.substring(0, name.length()-6).replace('$','.').replace('/','.'));
+            ClassFile cf = new ClassFile(new DataInputStream(zis));
+            cf.dump(out);
+        }
+        out.close();
+        outf.renameTo(inf);
+    }
+}