summaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authorjhugunin <jhugunin>2004-01-28 00:36:05 +0000
committerjhugunin <jhugunin>2004-01-28 00:36:05 +0000
commit6cceb1b9c3b53e92166d61435f28318e2b9a8872 (patch)
treebe2ceede849425dd4a40f9b103a059190b90d589 /weaver
parent098317da0a9bf6b3b12ca3f75c20b74fe42c0374 (diff)
downloadaspectj-6cceb1b9c3b53e92166d61435f28318e2b9a8872.tar.gz
aspectj-6cceb1b9c3b53e92166d61435f28318e2b9a8872.zip
fix for Bugzilla Bug 49295
duplicate warning or second join point for constructor-execution
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java50
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelShadow.java80
2 files changed, 65 insertions, 65 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
index 052cef1fa..d67d4eb87 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
@@ -391,7 +391,7 @@ class BcelClassWeaver implements IClassWeaver {
Range.genStart(body, body.getStart().getNext()),
Range.genEnd(body, call.getPrev()));
} else {
- // assert s.getKind() == Shadow.Initialization
+ // assert s.getKind() == Shadow.Initialization
r.associateWithTargets(
Range.genStart(body, call.getNext()),
Range.genEnd(body));
@@ -748,50 +748,40 @@ class BcelClassWeaver implements IClassWeaver {
// walk the body
boolean beforeSuperOrThisCall = true;
- if (shouldWeaveBody(mg)) { //!mg.isAjSynthetic()) {
- for (InstructionHandle h = mg.getBody().getStart();
- h != null;
- h = h.getNext()) {
- if (h == superOrThisCall) {
- beforeSuperOrThisCall = false;
- continue;
+ if (shouldWeaveBody(mg)) {
+ if (canMatchBodyShadows) {
+ for (InstructionHandle h = mg.getBody().getStart();
+ h != null;
+ h = h.getNext()) {
+ if (h == superOrThisCall) {
+ beforeSuperOrThisCall = false;
+ continue;
+ }
+ match(mg, h, beforeSuperOrThisCall ? null : enclosingShadow, shadowAccumulator);
}
- match(mg, h, beforeSuperOrThisCall ? null : enclosingShadow, shadowAccumulator);
}
match(enclosingShadow, shadowAccumulator);
}
// XXX we don't do pre-inits of interfaces
- // now add interface inits and cexecs
+ // now add interface inits
if (superOrThisCall != null && ! isThisCall(superOrThisCall)) {
InstructionHandle curr = enclosingShadow.getRange().getStart();
for (Iterator i = addedSuperInitializersAsList.iterator(); i.hasNext(); ) {
IfaceInitList l = (IfaceInitList) i.next();
- // generate the cexec jp
+
Member ifaceInitSig = AjcMemberMaker.interfaceConstructor(l.onType);
- BcelShadow cexecShadow =
- BcelShadow.makeIfaceConstructorExecution(
- world,
- mg,
- curr,
- ifaceInitSig);
- if (match(cexecShadow, shadowAccumulator)) {
- cexecShadow.getRange().getBody().append(
- cexecShadow.getRange().getStart(),
- InstructionConstants.NOP);
- }
- // generate the init jp around it
+
BcelShadow initShadow =
- BcelShadow.makeIfaceInitialization(
- world,
- mg,
- cexecShadow,
- ifaceInitSig);
- match(initShadow, shadowAccumulator);
+ BcelShadow.makeIfaceInitialization(world, mg, ifaceInitSig);
+
// insert code in place
InstructionList inits = genInitInstructions(l.list, false);
- initShadow.getRange().insert(inits, Range.InsideAfter);
+ if (match(initShadow, shadowAccumulator) || !inits.isEmpty()) {
+ initShadow.initIfaceInitializer(curr);
+ initShadow.getRange().insert(inits, Range.OutsideBefore);
+ }
}
// now we add our initialization code
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
index 41a84491a..fd72970cd 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
@@ -430,7 +430,6 @@ public class BcelShadow extends Shadow {
public static BcelShadow makeIfaceInitialization(
BcelWorld world,
LazyMethodGen constructor,
- BcelShadow ifaceCExecShadow,
Member interfaceConstructorSignature)
{
InstructionList body = constructor.getBody();
@@ -443,44 +442,55 @@ public class BcelShadow extends Shadow {
constructor,
null);
s.fallsThrough = true;
- ShadowRange r = new ShadowRange(body);
- r.associateWithShadow(s);
- InstructionHandle start = Range.genStart(body, ifaceCExecShadow.getRange().getStart());
- InstructionHandle end = Range.genEnd(body, ifaceCExecShadow.getRange().getEnd());
-
- r.associateWithTargets(start, end);
+// ShadowRange r = new ShadowRange(body);
+// r.associateWithShadow(s);
+// InstructionHandle start = Range.genStart(body, handle);
+// InstructionHandle end = Range.genEnd(body, handle);
+//
+// r.associateWithTargets(start, end);
return s;
}
-
- public static BcelShadow makeIfaceConstructorExecution(
- BcelWorld world,
- LazyMethodGen constructor,
- InstructionHandle next,
- Member interfaceConstructorSignature)
- {
- // final InstructionFactory fact = constructor.getEnclosingClass().getFactory();
- InstructionList body = constructor.getBody();
- // TypeX inType = constructor.getEnclosingClass().getType();
- BcelShadow s =
- new BcelShadow(
- world,
- ConstructorExecution,
- interfaceConstructorSignature,
- constructor,
- null);
- s.fallsThrough = true;
- ShadowRange r = new ShadowRange(body);
- r.associateWithShadow(s);
- // ??? this may or may not work
- InstructionHandle start = Range.genStart(body, next);
- //InstructionHandle end = Range.genEnd(body, body.append(start, fact.NOP));
- InstructionHandle end = Range.genStart(body, next);
- //body.append(start, fact.NOP);
-
- r.associateWithTargets(start, end);
- return s;
+
+ public void initIfaceInitializer(InstructionHandle end) {
+ final InstructionList body = enclosingMethod.getBody();
+ ShadowRange r = new ShadowRange(body);
+ r.associateWithShadow(this);
+ InstructionHandle nop = body.insert(end, InstructionConstants.NOP);
+
+ r.associateWithTargets(
+ Range.genStart(body, nop),
+ Range.genEnd(body, nop));
}
+// public static BcelShadow makeIfaceConstructorExecution(
+// BcelWorld world,
+// LazyMethodGen constructor,
+// InstructionHandle next,
+// Member interfaceConstructorSignature)
+// {
+// // final InstructionFactory fact = constructor.getEnclosingClass().getFactory();
+// InstructionList body = constructor.getBody();
+// // TypeX inType = constructor.getEnclosingClass().getType();
+// BcelShadow s =
+// new BcelShadow(
+// world,
+// ConstructorExecution,
+// interfaceConstructorSignature,
+// constructor,
+// null);
+// s.fallsThrough = true;
+// ShadowRange r = new ShadowRange(body);
+// r.associateWithShadow(s);
+// // ??? this may or may not work
+// InstructionHandle start = Range.genStart(body, next);
+// //InstructionHandle end = Range.genEnd(body, body.append(start, fact.NOP));
+// InstructionHandle end = Range.genStart(body, next);
+// //body.append(start, fact.NOP);
+//
+// r.associateWithTargets(start, end);
+// return s;
+// }
+
/** Create an initialization join point associated with a constructor, but not
* with any body of code yet. If this is actually matched, it's range will be set