aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2006-10-30 10:26:22 +0000
committeraclement <aclement>2006-10-30 10:26:22 +0000
commit26a4654ba4ebd7746b39fdf5d8f9122ea8246d61 (patch)
tree69bf4f31120a9267b206aa90595dabb224219947
parentb83891da5769442d335d8e61d52d16e215055975 (diff)
downloadaspectj-26a4654ba4ebd7746b39fdf5d8f9122ea8246d61.tar.gz
aspectj-26a4654ba4ebd7746b39fdf5d8f9122ea8246d61.zip
fix for 162657 - remove the matchesNothingPointcut which has no source context (can cause npe when reporting messages)
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/PointcutRewriter.java44
1 files changed, 35 insertions, 9 deletions
diff --git a/weaver/src/org/aspectj/weaver/patterns/PointcutRewriter.java b/weaver/src/org/aspectj/weaver/patterns/PointcutRewriter.java
index f43158048..b5ce1cf51 100644
--- a/weaver/src/org/aspectj/weaver/patterns/PointcutRewriter.java
+++ b/weaver/src/org/aspectj/weaver/patterns/PointcutRewriter.java
@@ -35,25 +35,51 @@ public class PointcutRewriter {
* See pr113257
*/
public Pointcut rewrite(Pointcut pc,boolean forceRewrite) {
- Pointcut result = pc;
+ Pointcut result = pc;//checkPC(result);
if (forceRewrite || !isDNF(pc)) {
if (WATCH_PROGRESS) System.out.println("Initial pointcut is ==> " + format(pc));
- result = distributeNot(result);
+ result = distributeNot(result);//checkPC(result);
if (WATCH_PROGRESS) System.out.println("Distributing NOT gives ==> " + format(result));
- result = pullUpDisjunctions(result);
+ result = pullUpDisjunctions(result);//checkPC(result);
if (WATCH_PROGRESS) System.out.println("Pull up disjunctions gives ==> " + format(result));
} else {
if (WATCH_PROGRESS) System.out.println("Not distributing NOTs or pulling up disjunctions, already DNF ==> "+format(pc));
}
- result = simplifyAnds(result);
+ result = simplifyAnds(result); // checkPC(result);
if (WATCH_PROGRESS) System.out.println("Simplifying ANDs gives ==> " + format(result));
- result = sortOrs(result);
+ result = removeNothings(result);// checkPC(result);
+ if (WATCH_PROGRESS) System.out.println("Removing nothings gives ==> " + format(result));
+ result = sortOrs(result);// checkPC(result);
if (WATCH_PROGRESS) System.out.println("Sorting ORs gives ==> " + format(result));
- //result = removeNothings(result);
- //if (WATCH_PROGRESS) System.out.println("Removing nothings gives ==> " + format(result));
return result;
}
+ /**
+ * Checks pointcuts - used for debugging.
+ * - this variant checks if the context has been lost, since
+ * that can indicate an NPE will happen later reporting a message (pr162657).
+ * Not finished, but helped locate the problem ;)
+ */
+ private void checkPC(Pointcut pc) {
+ if (isNot(pc)) {
+ NotPointcut npc = (NotPointcut)pc;
+ checkPC(npc.getNegatedPointcut());
+ if (npc.getSourceContext()==null) throw new RuntimeException("Lost context");
+ } else if (isOr(pc)) {
+ OrPointcut opc = (OrPointcut)pc;
+ checkPC(opc.getLeft());
+ checkPC(opc.getRight());
+ if (opc.getSourceContext()==null) throw new RuntimeException("Lost context");
+ } else if (isAnd(pc)) {
+ AndPointcut apc = (AndPointcut)pc;
+ checkPC(apc.getLeft());
+ checkPC(apc.getRight());
+ if (apc.getSourceContext()==null) throw new RuntimeException("Lost context");
+ } else {
+ if (pc.getSourceContext()==null) throw new RuntimeException("Lost context");
+ }
+ }
+
public Pointcut rewrite(Pointcut pc) {
return rewrite(pc,false);
}
@@ -147,7 +173,7 @@ public class PointcutRewriter {
private Pointcut pullUpDisjunctions(Pointcut pc) {
if (isNot(pc)) {
NotPointcut npc = (NotPointcut)pc;
- return new NotPointcut(pullUpDisjunctions(npc.getNegatedPointcut()));
+ return new NotPointcut(pullUpDisjunctions(npc.getNegatedPointcut()));
} else if (isAnd(pc)) {
AndPointcut apc = (AndPointcut) pc;
// dive into left and right here...
@@ -281,7 +307,7 @@ public class PointcutRewriter {
// !!X => X
return simplifyAnds(((NotPointcut)notBody).getNegatedPointcut());
} else {
- return new NotPointcut(simplifyAnds(npc.getNegatedPointcut()));
+ return new NotPointcut(simplifyAnds(npc.getNegatedPointcut()));
}
} else if (isOr(pc)) {
OrPointcut opc = (OrPointcut) pc;