summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-09-21 15:46:05 +0000
committeracolyer <acolyer>2005-09-21 15:46:05 +0000
commit0bb21718c148e8be91a8e49aad1d3fead4e06849 (patch)
tree3b04c061866f5b844abb274693bae5604dcd0136
parent4895aeff9da732f0f6f498158e09921844a5a792 (diff)
downloadaspectj-0bb21718c148e8be91a8e49aad1d3fead4e06849.tar.gz
aspectj-0bb21718c148e8be91a8e49aad1d3fead4e06849.zip
tests and fix for pr102210 - not descending into branches when pulling up disjunctions during pointcut rewriting.
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java3
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java16
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/PointcutRewriter.java27
3 files changed, 33 insertions, 13 deletions
diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
index 5d31fbb16..373e21f28 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
@@ -195,7 +195,8 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
public void testSyntaxErrorNPE_pr103266() {runTest("NPE on syntax error");}
public void testFinalAbstractClass_pr109486() { runTest("Internal compiler error (ClassParser.java:242)");}
- //public void testComplexBinding_pr102210() { runTest("NullPointerException trying to compile");}
+
+ public void testComplexBinding_pr102210() { runTest("NullPointerException trying to compile");}
public void testIllegalStateExceptionOnNestedParameterizedType_pr106634() {
runTest("IllegalStateException unpacking signature of nested parameterized type");
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
index 45b1bb869..3549d4872 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
@@ -683,7 +683,21 @@ public class BcelWeaver implements IWeaver {
// the effects of itds (on within for example), interfaces, the fact that
// join points can have multiple signatures and so on.
private boolean couldEverMatchSameJoinPoints(Pointcut left, Pointcut right) {
- if ((left instanceof OrPointcut) || (right instanceof OrPointcut)) return true;
+
+ if (left instanceof OrPointcut) {
+ OrPointcut leftOrPointcut = (OrPointcut)left;
+ if (couldEverMatchSameJoinPoints(leftOrPointcut.getLeft(),right)) return true;
+ if (couldEverMatchSameJoinPoints(leftOrPointcut.getRight(),right)) return true;
+ return false;
+ }
+
+ if (right instanceof OrPointcut) {
+ OrPointcut rightOrPointcut = (OrPointcut)right;
+ if (couldEverMatchSameJoinPoints(left,rightOrPointcut.getLeft())) return true;
+ if (couldEverMatchSameJoinPoints(left,rightOrPointcut.getRight())) return true;
+ return false;
+ }
+
// look for withins
WithinPointcut leftWithin = (WithinPointcut) findFirstPointcutIn(left,WithinPointcut.class);
WithinPointcut rightWithin = (WithinPointcut) findFirstPointcutIn(right,WithinPointcut.class);
diff --git a/weaver/src/org/aspectj/weaver/patterns/PointcutRewriter.java b/weaver/src/org/aspectj/weaver/patterns/PointcutRewriter.java
index f6383e575..fed2d7046 100644
--- a/weaver/src/org/aspectj/weaver/patterns/PointcutRewriter.java
+++ b/weaver/src/org/aspectj/weaver/patterns/PointcutRewriter.java
@@ -27,19 +27,20 @@ public class PointcutRewriter {
private static final boolean WATCH_PROGRESS = false;
public Pointcut rewrite(Pointcut pc) {
- if (WATCH_PROGRESS) System.out.println(pc);
+ if (WATCH_PROGRESS) System.out.println("Initial pointcut is ==> " + pc);
Pointcut result = distributeNot(pc);
- if (WATCH_PROGRESS) System.out.println("==> " + result);
+ if (WATCH_PROGRESS) System.out.println("Distributing NOT gives ==> " + result);
result = pullUpDisjunctions(result);
- if (WATCH_PROGRESS) System.out.println("==> " + result);
+ if (WATCH_PROGRESS) System.out.println("Pull up disjunctions gives ==> " + result);
result = simplifyAnds(result);
- if (WATCH_PROGRESS) System.out.println("==> " + result);
+ if (WATCH_PROGRESS) System.out.println("Simplifying ANDs gives ==> " + result);
result = sortOrs(result);
- if (WATCH_PROGRESS) System.out.println("==> " + result);
+ if (WATCH_PROGRESS) System.out.println("Sorting ORs gives ==> " + result);
return result;
}
+
// !!X => X
// !(X && Y) => !X || !Y
// !(X || Y) => !X && !Y
@@ -95,16 +96,20 @@ public class PointcutRewriter {
// (A || B) && C => (A && C) || (B && C)
Pointcut leftLeft = ((OrPointcut)left).getLeft();
Pointcut leftRight = ((OrPointcut)left).getRight();
- return new OrPointcut(
- new AndPointcut(leftLeft,right),
- new AndPointcut(leftRight,right));
+ return pullUpDisjunctions(
+ new OrPointcut(
+ new AndPointcut(leftLeft,right),
+ new AndPointcut(leftRight,right))
+ );
} else if (isOr(right) && !isOr(left)) {
// A && (B || C) => (A && B) || (A && C)
Pointcut rightLeft = ((OrPointcut)right).getLeft();
Pointcut rightRight = ((OrPointcut)right).getRight();
- return new OrPointcut(
- new AndPointcut(left,rightLeft),
- new AndPointcut(left,rightRight));
+ return pullUpDisjunctions(
+ new OrPointcut(
+ new AndPointcut(left,rightLeft),
+ new AndPointcut(left,rightRight))
+ );
} else {
return new AndPointcut(left,right);