aboutsummaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authorjhugunin <jhugunin>2003-01-22 01:25:44 +0000
committerjhugunin <jhugunin>2003-01-22 01:25:44 +0000
commitdcb2473da044211101743c8dd1fa8f21d55e29cd (patch)
tree62027508d60033f4c8857db63a7da3f708dc6281 /weaver
parentc5b90daa74db7a3278260de33625a75bdf0151e0 (diff)
downloadaspectj-dcb2473da044211101743c8dd1fa8f21d55e29cd.tar.gz
aspectj-dcb2473da044211101743c8dd1fa8f21d55e29cd.zip
fix for failing test case that aspects must be constructed after their
clinit has run
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/AjcMemberMaker.java13
-rw-r--r--weaver/src/org/aspectj/weaver/NameMangler.java4
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelCflowStackFieldAdder.java2
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelShadow.java28
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java6
-rw-r--r--weaver/testdata/dummyAspect.jarbin589 -> 589 bytes
-rw-r--r--weaver/testdata/megatrace.jarbin3555 -> 3558 bytes
-rw-r--r--weaver/testdata/megatraceNoweave.jarbin2709 -> 2712 bytes
-rw-r--r--weaver/testdata/tracing.jarbin2291 -> 2293 bytes
9 files changed, 39 insertions, 14 deletions
diff --git a/weaver/src/org/aspectj/weaver/AjcMemberMaker.java b/weaver/src/org/aspectj/weaver/AjcMemberMaker.java
index 2a63a6e5e..ae29a0d4c 100644
--- a/weaver/src/org/aspectj/weaver/AjcMemberMaker.java
+++ b/weaver/src/org/aspectj/weaver/AjcMemberMaker.java
@@ -40,12 +40,21 @@ public class AjcMemberMaker {
public static final TypeX NO_ASPECT_BOUND_EXCEPTION =
TypeX.forName("org.aspectj.lang.NoAspectBoundException");
- public static ResolvedMember ajcClinitMethod(TypeX declaringType) {
+ public static ResolvedMember ajcPreClinitMethod(TypeX declaringType) {
return new ResolvedMember(
Member.METHOD,
declaringType,
PRIVATE_STATIC,
- NameMangler.AJC_CLINIT_NAME,
+ NameMangler.AJC_PRE_CLINIT_NAME,
+ "()V");
+ }
+
+ public static ResolvedMember ajcPostClinitMethod(TypeX declaringType) {
+ return new ResolvedMember(
+ Member.METHOD,
+ declaringType,
+ PRIVATE_STATIC,
+ NameMangler.AJC_POST_CLINIT_NAME,
"()V");
}
diff --git a/weaver/src/org/aspectj/weaver/NameMangler.java b/weaver/src/org/aspectj/weaver/NameMangler.java
index f3a9e4c28..e510cc3e7 100644
--- a/weaver/src/org/aspectj/weaver/NameMangler.java
+++ b/weaver/src/org/aspectj/weaver/NameMangler.java
@@ -39,7 +39,9 @@ public class NameMangler {
public static final String PEROBJECT_BIND_METHOD = PREFIX + "perObjectBind";
- public static final String AJC_CLINIT_NAME = PREFIX + "clinit";
+ public static final String AJC_PRE_CLINIT_NAME = PREFIX + "preClinit";
+
+ public static final String AJC_POST_CLINIT_NAME = PREFIX + "postClinit";
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelCflowStackFieldAdder.java b/weaver/src/org/aspectj/weaver/bcel/BcelCflowStackFieldAdder.java
index 75c515218..405e28cb3 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelCflowStackFieldAdder.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelCflowStackFieldAdder.java
@@ -36,7 +36,7 @@ public class BcelCflowStackFieldAdder extends BcelTypeMunger {
gen.getConstantPoolGen()).getField();
gen.addField(f);
- LazyMethodGen clinit = gen.getAjcClinit(); //StaticInitializer();
+ LazyMethodGen clinit = gen.getAjcPreClinit(); //StaticInitializer();
InstructionList setup = new InstructionList();
InstructionFactory fact = gen.getFactory();
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
index bd8c76288..26d2d7f1d 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
@@ -309,13 +309,27 @@ public class BcelShadow extends Shadow {
LazyMethodGen enclosingMethod)
{
InstructionList body = enclosingMethod.getBody();
- InstructionHandle ih = body.getStart();
- if (ih.getInstruction() instanceof InvokeInstruction) {
- InvokeInstruction ii = (InvokeInstruction)ih.getInstruction();
- if (ii.getName(enclosingMethod.getEnclosingClass().getConstantPoolGen()).equals(NameMangler.AJC_CLINIT_NAME)) {
- ih = ih.getNext();
+ // move the start past ajc$preClinit
+ InstructionHandle clinitStart = body.getStart();
+ if (clinitStart.getInstruction() instanceof InvokeInstruction) {
+ InvokeInstruction ii = (InvokeInstruction)clinitStart.getInstruction();
+ if (ii.getName(enclosingMethod.getEnclosingClass().getConstantPoolGen()).equals(NameMangler.AJC_PRE_CLINIT_NAME)) {
+ clinitStart = clinitStart.getNext();
}
}
+
+ InstructionHandle clinitEnd = body.getEnd();
+
+ //XXX should move the end before the postClinit, but the return is then tricky...
+// if (clinitEnd.getInstruction() instanceof InvokeInstruction) {
+// InvokeInstruction ii = (InvokeInstruction)clinitEnd.getInstruction();
+// if (ii.getName(enclosingMethod.getEnclosingClass().getConstantPoolGen()).equals(NameMangler.AJC_POST_CLINIT_NAME)) {
+// clinitEnd = clinitEnd.getPrev();
+// }
+// }
+
+
+
BcelShadow s =
new BcelShadow(
world,
@@ -326,8 +340,8 @@ public class BcelShadow extends Shadow {
ShadowRange r = new ShadowRange(body);
r.associateWithShadow(s);
r.associateWithTargets(
- Range.genStart(body, ih),
- Range.genEnd(body));
+ Range.genStart(body, clinitStart),
+ Range.genEnd(body, clinitEnd));
return s;
}
diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java
index 0953d1884..da0a2db8f 100644
--- a/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java
+++ b/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java
@@ -319,15 +319,15 @@ public final class LazyClassGen {
return clinit;
}
- public LazyMethodGen getAjcClinit() {
+ public LazyMethodGen getAjcPreClinit() {
for (Iterator i = methodGens.iterator(); i.hasNext();) {
LazyMethodGen gen = (LazyMethodGen) i.next();
- if (gen.getName().equals(NameMangler.AJC_CLINIT_NAME)) return gen;
+ if (gen.getName().equals(NameMangler.AJC_PRE_CLINIT_NAME)) return gen;
}
LazyMethodGen ajcClinit = new LazyMethodGen(
Modifier.STATIC,
Type.VOID,
- NameMangler.AJC_CLINIT_NAME,
+ NameMangler.AJC_PRE_CLINIT_NAME,
new Type[0],
CollectionUtil.NO_STRINGS,
this);
diff --git a/weaver/testdata/dummyAspect.jar b/weaver/testdata/dummyAspect.jar
index 100b7d8f1..54b76f013 100644
--- a/weaver/testdata/dummyAspect.jar
+++ b/weaver/testdata/dummyAspect.jar
Binary files differ
diff --git a/weaver/testdata/megatrace.jar b/weaver/testdata/megatrace.jar
index 927615c58..8c0843c28 100644
--- a/weaver/testdata/megatrace.jar
+++ b/weaver/testdata/megatrace.jar
Binary files differ
diff --git a/weaver/testdata/megatraceNoweave.jar b/weaver/testdata/megatraceNoweave.jar
index 8a6273995..dba8efbff 100644
--- a/weaver/testdata/megatraceNoweave.jar
+++ b/weaver/testdata/megatraceNoweave.jar
Binary files differ
diff --git a/weaver/testdata/tracing.jar b/weaver/testdata/tracing.jar
index 99744a6bc..18bf1b759 100644
--- a/weaver/testdata/tracing.jar
+++ b/weaver/testdata/tracing.jar
Binary files differ