- // build package path to new class file
- File path = builddir;
- char[][] name = c[i].getCompoundName();
- path = new File(builddir, str(pack(name), '/'));
- if (!path.exists()) path.mkdirs();
-
- // write new class file
- path = new File(path, new String(name(name)) + ".class");
- OutputStream o = new BufferedOutputStream(
- new FileOutputStream(path));
- o.write(c[i].getBytes());
- o.close();
+ char[][] name = c[i].getCompoundName();
+ if (buildzip) {
+ try {
+ jarfile.putNextEntry(new ZipEntry(str(pack(name), '/') + "/" + new String(name(name)) + ".class"));
+ jarfile.write(c[i].getBytes());
+ } catch (java.util.zip.ZipException ze) {
+ // HACK: horrendous hack
+ if (ze.getMessage().indexOf("duplicate entry") != -1) {
+ System.err.println("compiler emitted class twice: " + new String(name(name)));
+ } else {
+ throw ze;
+ }
+ }
+ } else {
+ // build package path to new class file
+ File path = new File(builddir, str(pack(name), '/'));
+ if (!path.exists()) path.mkdirs();
+ // write new class file
+ path = new File(path, new String(name(name)) + ".class");
+ OutputStream o = new BufferedOutputStream(new FileOutputStream(path));
+ o.write(c[i].getBytes());
+ o.close();
+ }