Index: src/org/aspectj/weaver/bcel/BcelWeaver.java =================================================================== RCS file: /home/technology/org.aspectj/modules/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java,v retrieving revision 1.13 diff -u -r1.13 BcelWeaver.java --- src/org/aspectj/weaver/bcel/BcelWeaver.java 1 May 2003 19:47:44 -0000 1.13 +++ src/org/aspectj/weaver/bcel/BcelWeaver.java 30 Jul 2003 16:47:39 -0000 @@ -47,6 +47,7 @@ private Map sourceJavaClasses = new HashMap(); /* String -> UnwovenClassFile */ private List addedClasses = new ArrayList(); /* List */ private List deletedTypenames = new ArrayList(); /* List */ + private Map resources = new HashMap(); /* String -> byte[] */ private boolean needToReweaveWorld = false; private List shadowMungerList = null; // setup by prepareForWeave @@ -119,20 +120,26 @@ ZipEntry entry = inStream.getNextEntry(); if (entry == null) break; + byte[] bytes = FileUtil.readAsByteArray(inStream); + String filename = entry.getName(); + if (entry.isDirectory() || !entry.getName().endsWith(".class")) { + System.out.println("? " + getClass().getName() + ".addJarFile() entry=" + entry); + addResource(filename,bytes); + continue; //??? need to pass other things along untouched // outStream.putNextEntry(entry); // outStream.write(Utility.getByteArray(inStream)); // outStream.closeEntry(); // return; } - //System.err.println("adding class: " + entry.getName()); - - byte[] bytes = FileUtil.readAsByteArray(inStream); - String filename = entry.getName(); - UnwovenClassFile classFile = new UnwovenClassFile(new File(outDir, filename).getAbsolutePath(), bytes); - inStream.closeEntry(); - this.addClassFile(classFile); + else { + UnwovenClassFile classFile = new UnwovenClassFile(new File(outDir, filename).getAbsolutePath(), bytes); + inStream.closeEntry(); + this.addClassFile(classFile); + //System.err.println("adding class: " + entry.getName()); + } + } inStream.close(); @@ -154,6 +161,10 @@ world.deleteSourceObjectType(TypeX.forName(typename)); } + public void addResource (String name, byte[] bytes) { + resources.put(name,bytes); + } + // ---- weave preparation public void prepareForWeave() { @@ -191,10 +202,14 @@ } public void dumpUnwoven(File file) throws IOException { + System.out.println("> " + getClass().getName() + ".dumpUnwoven(" + file + ")"); BufferedOutputStream os = FileUtil.makeOutputStream(file); this.zipOutputStream = new ZipOutputStream(os); dumpUnwoven(); + /* BUG 40943*/ + dumpResources(); zipOutputStream.close(); //this flushes and closes the acutal file + System.out.println("< " + getClass().getName() + ".dumpUnwoven()"); } @@ -206,18 +221,37 @@ } } + /* BUG #40943 */ + public void dumpResources () throws IOException { + System.out.println("> " + getClass().getName() + ".dumpResources()"); + + Iterator iter = resources.keySet().iterator(); + while (iter.hasNext()) { + String name = (String)iter.next(); + byte[] bytes = (byte[])resources.get(name); + System.out.println(" " + getClass().getName() + ".dumpResources() " + name); + writeZipEntry(name,bytes); + } + + System.out.println("< " + getClass().getName() + ".dumpResources()"); + } // ---- weaving public Collection weave(File file) throws IOException { + System.out.println("> " + getClass().getName() + ".weave(" + file + ")"); OutputStream os = FileUtil.makeOutputStream(file); this.zipOutputStream = new ZipOutputStream(os); Collection c = weave(); + /* BUG 40943*/ + dumpResources(); zipOutputStream.close(); //this flushes and closes the acutal file + System.out.println("< " + getClass().getName() + ".weave()"); return c; } public Collection weave() throws IOException { + System.out.println("> " + getClass().getName() + ".weave()"); prepareForWeave(); Collection filesToWeave; @@ -286,6 +320,7 @@ addedClasses = new ArrayList(); deletedTypenames = new ArrayList(); + System.out.println("< " + getClass().getName() + ".weave()"); return wovenClassNames; } @@ -422,6 +457,7 @@ } private void writeZipEntry(String name, byte[] bytes) throws IOException { + System.out.println("? " + getClass().getName() + ".writeZipEntry() name='" + name +"'"); ZipEntry newEntry = new ZipEntry(name); //??? get compression scheme right zipOutputStream.putNextEntry(newEntry);