summaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authoraclement <aclement>2004-08-02 15:47:02 +0000
committeraclement <aclement>2004-08-02 15:47:02 +0000
commit2b8fa314f21eddf8551715fdd571da2b611411d0 (patch)
treeb1d79b311bdd55ff5a6c5fb205c77896dc5222b5 /weaver
parent7f19ab47a3df5327c6246420354089d1db1c765f (diff)
downloadaspectj-2b8fa314f21eddf8551715fdd571da2b611411d0.tar.gz
aspectj-2b8fa314f21eddf8551715fdd571da2b611411d0.zip
Fix for Bugzilla Bug 57666
duplicate manifests cause resource-copying to gack (Contributed by Matthew Webster)
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java31
1 files changed, 20 insertions, 11 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
index 6fd891ca6..19beb0f62 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
@@ -20,17 +20,21 @@ import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
+import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.jar.Attributes;
import java.util.jar.Attributes.Name;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
@@ -181,7 +185,7 @@ public class BcelWeaver implements IWeaver {
// System.err.println("? addJarFile(" + inFile + ", " + outDir + ")");
List addedClassFiles = new ArrayList();
needToReweaveWorld = true;
- JarInputStream inStream = null;
+ JarFile inJar = null;
try {
// Is this a directory we are looking at?
@@ -189,15 +193,17 @@ public class BcelWeaver implements IWeaver {
addedClassFiles.addAll(addDirectoryContents(inFile,outDir));
} else {
- inStream = new JarInputStream(new FileInputStream(inFile)); //??? buffered
- addManifest(inStream.getManifest());
+ inJar = new JarFile(inFile);
+ addManifest(inJar.getManifest());
+ Enumeration entries = inJar.entries();
- while (true) {
- ZipEntry entry = inStream.getNextEntry();
- if (entry == null) break;
-
+ while (entries.hasMoreElements()) {
+ JarEntry entry = (JarEntry)entries.nextElement();
+ InputStream inStream = inJar.getInputStream(entry);
+
byte[] bytes = FileUtil.readAsByteArray(inStream);
String filename = entry.getName();
+// System.out.println("? addJarFile() filename='" + filename + "'");
UnwovenClassFile classFile = new UnwovenClassFile(new File(outDir, filename).getAbsolutePath(), bytes);
if (filename.endsWith(".class")) {
@@ -210,9 +216,9 @@ public class BcelWeaver implements IWeaver {
// addResource(filename,classFile);
// }
- inStream.closeEntry();
+ inStream.close();
}
- inStream.close();
+ inJar.close();
}
} catch (FileNotFoundException ex) {
IMessage message = new Message(
@@ -227,8 +233,8 @@ public class BcelWeaver implements IWeaver {
true);
world.getMessageHandler().handleMessage(message);
} finally {
- if (inStream != null) {
- try {inStream.close();}
+ if (inJar != null) {
+ try {inJar.close();}
catch (IOException ex) {
IMessage message = new Message(
"Could not close input jar file " + inFile.getPath() + "(" + ex.getMessage() + ")",
@@ -391,11 +397,14 @@ public class BcelWeaver implements IWeaver {
// }
public void addManifest (Manifest newManifest) {
+// System.out.println("? addManifest() newManifest=" + newManifest);
if (manifest == null) {
manifest = newManifest;
}
}
+ public static final String MANIFEST_NAME = "META-INF/MANIFEST.MF";
+
private static final String WEAVER_MANIFEST_VERSION = "1.0";
private static final Attributes.Name CREATED_BY = new Name("Created-By");
private static final String WEAVER_CREATED_BY = "AspectJ Compiler";