diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2023-01-29 17:14:05 +0100 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2023-01-29 18:01:42 +0100 |
commit | 53bb964c3021b18dc94c4dfb66b212bd0060449c (patch) | |
tree | 5d9f33bdf887b04897731ffa7cbad4c56e8c8a39 | |
parent | 6585b9ef46e9cf6402a2d2ec5107443218488dc1 (diff) | |
download | aspectj-53bb964c3021b18dc94c4dfb66b212bd0060449c.tar.gz aspectj-53bb964c3021b18dc94c4dfb66b212bd0060449c.zip |
Add safeguards for And/Or/Not pattern node types
Affects *PointCut, *TypePattern, *AnnotationTypePattern.
Relates to #215.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
9 files changed, 30 insertions, 15 deletions
diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AndAnnotationTypePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AndAnnotationTypePattern.java index fed3db0f6..3312e4e08 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AndAnnotationTypePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AndAnnotationTypePattern.java @@ -130,8 +130,10 @@ public class AndAnnotationTypePattern extends AnnotationTypePattern { public Object traverse(PatternNodeVisitor visitor, Object data) { Object ret = accept(visitor, data); - left.traverse(visitor, ret); - right.traverse(visitor, ret); + if (this.left != null) + this.left.traverse(visitor, ret); + if (this.right != null) + this.right.traverse(visitor, ret); return ret; } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AndPointcut.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AndPointcut.java index b2b5bd0d6..5804db298 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AndPointcut.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AndPointcut.java @@ -131,8 +131,10 @@ public class AndPointcut extends Pointcut { public Object traverse(PatternNodeVisitor visitor, Object data) { Object ret = accept(visitor, data); - left.traverse(visitor, ret); - right.traverse(visitor, ret); + if (this.left != null) + this.left.traverse(visitor, ret); + if (this.right != null) + this.right.traverse(visitor, ret); return ret; } } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AndTypePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AndTypePattern.java index e4099a692..52c269819 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AndTypePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AndTypePattern.java @@ -195,8 +195,10 @@ public class AndTypePattern extends TypePattern { @Override public Object traverse(PatternNodeVisitor visitor, Object data) { Object ret = accept(visitor, data); - left.traverse(visitor, ret); - right.traverse(visitor, ret); + if (this.left != null) + this.left.traverse(visitor, ret); + if (this.right != null) + this.right.traverse(visitor, ret); return ret; } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/NotAnnotationTypePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/NotAnnotationTypePattern.java index 665d35281..921abca41 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/NotAnnotationTypePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/NotAnnotationTypePattern.java @@ -126,7 +126,8 @@ public class NotAnnotationTypePattern extends AnnotationTypePattern { public Object traverse(PatternNodeVisitor visitor, Object data) { Object ret = accept(visitor, data); - negatedPattern.traverse(visitor, ret); + if (this.negatedPattern != null) + this.negatedPattern.traverse(visitor, ret); return ret; } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/NotPointcut.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/NotPointcut.java index 2179f8b61..bd572f469 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/NotPointcut.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/NotPointcut.java @@ -133,7 +133,8 @@ public class NotPointcut extends Pointcut { @Override public Object traverse(PatternNodeVisitor visitor, Object data) { Object ret = accept(visitor, data); - this.body.traverse(visitor, ret); + if (this.body != null) + this.body.traverse(visitor, ret); return ret; } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/NotTypePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/NotTypePattern.java index b5c5aee5a..d8c4f3bd4 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/NotTypePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/NotTypePattern.java @@ -178,7 +178,8 @@ public class NotTypePattern extends TypePattern { @Override public Object traverse(PatternNodeVisitor visitor, Object data) { Object ret = accept(visitor, data); - negatedPattern.traverse(visitor, ret); + if (this.negatedPattern != null) + this.negatedPattern.traverse(visitor, ret); return ret; } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/OrAnnotationTypePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/OrAnnotationTypePattern.java index c00a1dcbe..e06e9c1ed 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/OrAnnotationTypePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/OrAnnotationTypePattern.java @@ -69,8 +69,10 @@ public class OrAnnotationTypePattern extends AnnotationTypePattern { public Object traverse(PatternNodeVisitor visitor, Object data) { Object ret = accept(visitor, data); - left.traverse(visitor, ret); - right.traverse(visitor, ret); + if (this.left != null) + this.left.traverse(visitor, ret); + if (this.right != null) + this.right.traverse(visitor, ret); return ret; } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/OrPointcut.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/OrPointcut.java index a07f98831..254fce9e5 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/OrPointcut.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/OrPointcut.java @@ -139,8 +139,10 @@ public class OrPointcut extends Pointcut { public Object traverse(PatternNodeVisitor visitor, Object data) { Object ret = accept(visitor, data); - left.traverse(visitor, ret); - right.traverse(visitor, ret); + if (this.left != null) + this.left.traverse(visitor, ret); + if (this.right != null) + this.right.traverse(visitor, ret); return ret; } } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/OrTypePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/OrTypePattern.java index 627c4a7d0..287dc2dc3 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/OrTypePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/OrTypePattern.java @@ -190,8 +190,10 @@ public class OrTypePattern extends TypePattern { public Object traverse(PatternNodeVisitor visitor, Object data) { Object ret = accept(visitor, data); - left.traverse(visitor, ret); - right.traverse(visitor, ret); + if (this.left != null) + this.left.traverse(visitor, ret); + if (this.right != null) + this.right.traverse(visitor, ret); return ret; } |