aboutsummaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authorjhugunin <jhugunin>2003-02-14 01:59:11 +0000
committerjhugunin <jhugunin>2003-02-14 01:59:11 +0000
commitfd1aaf0ccd8631a022affbf51bfff9e9dfa0d71a (patch)
tree3a8ce111f97f0b99285882fd16b478310ee207aa /weaver
parent8e6cef02952075a7ad3c43229bb48bea159a6cb8 (diff)
downloadaspectj-fd1aaf0ccd8631a022affbf51bfff9e9dfa0d71a.tar.gz
aspectj-fd1aaf0ccd8631a022affbf51bfff9e9dfa0d71a.zip
applying Martin Lippert's patch in support of a weaving class loader
made some modifications to avoid duplication of code from weave method
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java2
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java25
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelWorld.java6
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/ClassPathManager.java43
-rw-r--r--weaver/testsrc/org/aspectj/weaver/bcel/WeaveTestCase.java2
5 files changed, 51 insertions, 27 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java
index c99b773ee..109e91498 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java
@@ -182,7 +182,7 @@ public class BcelObjectType extends ResolvedTypeX.Name {
return javaClass;
}
- void resetState() {
+ public void resetState() {
this.interfaces = null;
this.superClass = null;
this.fields = null;
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
index 53ccfd705..8e02045be 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
@@ -281,7 +281,7 @@ public class BcelWeaver implements IWeaver {
return wovenClassNames;
}
- private void weave(ResolvedTypeX onType) {
+ public void weave(ResolvedTypeX onType) {
onType.clearInterTypeMungers();
for (Iterator i = typeMungerList.iterator(); i.hasNext(); ) {
ConcreteTypeMunger m = (ConcreteTypeMunger)i.next();
@@ -291,11 +291,19 @@ public class BcelWeaver implements IWeaver {
}
}
+ // exposed for ClassLoader dynamic weaving
+ public LazyClassGen weaveWithoutDump(UnwovenClassFile classFile, BcelObjectType classType) throws IOException {
+ return weave(classFile, classType, false);
+ }
// non-private for testing
LazyClassGen weave(UnwovenClassFile classFile, BcelObjectType classType) throws IOException {
+ return weave(classFile, classType, true);
+ }
+
+ private LazyClassGen weave(UnwovenClassFile classFile, BcelObjectType classType, boolean dump) throws IOException {
if (classType.isSynthetic()) {
- dumpUnchanged(classFile);
+ if (dump) dumpUnchanged(classFile);
return null;
}
@@ -311,7 +319,7 @@ public class BcelWeaver implements IWeaver {
try {
boolean isChanged = BcelClassWeaver.weave(world, clazz, shadowMungers, typeMungers);
if (isChanged) {
- dump(classFile, clazz);
+ if (dump) dump(classFile, clazz);
return clazz;
}
} catch (RuntimeException re) {
@@ -325,10 +333,17 @@ public class BcelWeaver implements IWeaver {
}
}
- dumpUnchanged(classFile);
- return clazz;
+ // this is very odd return behavior trying to keep everyone happy
+ if (dump) {
+ dumpUnchanged(classFile);
+ return clazz;
+ } else {
+ return null;
+ }
}
+
+
// ---- writing
private void dumpUnchanged(UnwovenClassFile classFile) throws IOException {
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java b/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
index 9c5e91c4e..539bb7dee 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
@@ -70,6 +70,10 @@ public class BcelWorld extends World {
setMessageHandler(handler);
}
+ public void addPath (String name) {
+ classPath.addPath(name, this.getMessageHandler());
+ }
+
/**
* Parse a string into advice.
*
@@ -191,7 +195,7 @@ public class BcelWorld extends World {
}
- BcelObjectType addSourceObjectType(JavaClass jc) {
+ public BcelObjectType addSourceObjectType(JavaClass jc) {
String signature = TypeX.forName(jc.getClassName()).getSignature();
BcelObjectType ret = (BcelObjectType)typeMap.get(signature);
if (ret == null) {
diff --git a/weaver/src/org/aspectj/weaver/bcel/ClassPathManager.java b/weaver/src/org/aspectj/weaver/bcel/ClassPathManager.java
index d8e2ad5f4..ee2b55e6a 100644
--- a/weaver/src/org/aspectj/weaver/bcel/ClassPathManager.java
+++ b/weaver/src/org/aspectj/weaver/bcel/ClassPathManager.java
@@ -32,29 +32,34 @@ public class ClassPathManager {
entries = new ArrayList();
for (Iterator i = classpath.iterator(); i.hasNext();) {
String name = (String) i.next();
- File f = new File(name);
- String lc = name.toLowerCase();
- if (lc.endsWith(".jar") || lc.endsWith(".zip")) {
- if (!f.isFile()) {
- MessageUtil.info(handler, "zipfile classpath entry does not exist: " + name);
- continue;
- }
- try {
- entries.add(new ZipFileEntry(f));
- } catch (IOException ioe) {
- MessageUtil.warn(handler, "zipfile classpath entry is invalid: " + name + "<" + ioe.getMessage() + ">");
- continue;
- }
- } else {
- if (!f.isDirectory()) {
- MessageUtil.info(handler, "directory classpath entry does not exist: " + name);
- continue;
- }
- entries.add(new DirEntry(f));
+ addPath(name, handler);
+ }
+ }
+
+ public void addPath (String name, IMessageHandler handler) {
+ File f = new File(name);
+ String lc = name.toLowerCase();
+ if (lc.endsWith(".jar") || lc.endsWith(".zip")) {
+ if (!f.isFile()) {
+ MessageUtil.info(handler, "zipfile classpath entry does not exist: " + name);
+ return;
}
+ try {
+ entries.add(new ZipFileEntry(f));
+ } catch (IOException ioe) {
+ MessageUtil.warn(handler, "zipfile classpath entry is invalid: " + name + "<" + ioe.getMessage() + ">");
+ return;
+ }
+ } else {
+ if (!f.isDirectory()) {
+ MessageUtil.info(handler, "directory classpath entry does not exist: " + name);
+ return;
+ }
+ entries.add(new DirEntry(f));
}
}
+
public ClassFile find(TypeX type) {
String name = type.getName();
for (Iterator i = entries.iterator(); i.hasNext(); ) {
diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/WeaveTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/WeaveTestCase.java
index e0cc600fe..3bdcae8ce 100644
--- a/weaver/testsrc/org/aspectj/weaver/bcel/WeaveTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/bcel/WeaveTestCase.java
@@ -80,7 +80,7 @@ public abstract class WeaveTestCase extends TestCase {
LazyClassGen gen = weaver.weave(classFile, classType);
if (gen == null) {
// we didn't do any weaving, but let's make a gen anyway
- gen = new LazyClassGen(classType);
+ gen = classType.getLazyClassGen(); //new LazyClassGen(classType);
}
try {
checkClass(gen, outDir, outName + ".txt");