From a4caeb95261431c81f7beb0cddbff3b0865e614d Mon Sep 17 00:00:00 2001 From: acolyer Date: Wed, 23 Nov 2005 16:20:19 +0000 Subject: tests and fix for pr114054 (erroneous handling of negation in per-object perclauses) --- tests/bugs150/Pr114054.aj | 30 ++++++++++++++++++++++ .../org/aspectj/systemtest/ajc150/Ajc150Tests.java | 4 +++ tests/src/org/aspectj/systemtest/ajc150/ajc150.xml | 5 ++++ .../patterns/PerThisOrTargetPointcutVisitor.java | 13 ++++++---- 4 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 tests/bugs150/Pr114054.aj diff --git a/tests/bugs150/Pr114054.aj b/tests/bugs150/Pr114054.aj new file mode 100644 index 000000000..3f776df43 --- /dev/null +++ b/tests/bugs150/Pr114054.aj @@ -0,0 +1,30 @@ +public class Pr114054 { + public static boolean passed; + public static void main(String[] args) { + SampleSeries me = new SampleSeries(); + me.okSeries(); + me.open(); + me.close(); + if (!passed) { + throw new Error("failed to advise..."); + } + } + static class SampleSeries { + void open() {} + void close() {} + void okSeries() {open(); close();} + } + static aspect AAAA + // comment this out, and !call(...) works + pertarget(tracked()) + { + protected final pointcut tracked() : + call(void SampleSeries.*()) + // comment this out, and pertarget works... + && !call(void SampleSeries.*Series()) + ; + before() : tracked() { + Pr114054.passed = true; + } + } +} \ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index be703cb03..41960b5ae 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -739,6 +739,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { runTest("returning(Object) binding"); } + public void testPerTargetAndNegation() { + runTest("pertarget and negated pointcut"); + } + /* * Load-time weaving bugs */ diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 5b072abf7..19a8c0f2f 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -37,6 +37,11 @@ + + + + + diff --git a/weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java b/weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java index da8271721..daaf2d5e1 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java +++ b/weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java @@ -113,11 +113,14 @@ public class PerThisOrTargetPointcutVisitor extends IdentityPointcutVisitor { } public Object visit(NotPointcut node, Object data) { - TypePattern negated = getPerTypePointcut(node.getNegatedPointcut()); - if (MAYBE.equals(negated)) { - return MAYBE; - } - return new NotTypePattern(negated); +// TypePattern negated = getPerTypePointcut(node.getNegatedPointcut()); +// if (MAYBE.equals(negated)) { +// return MAYBE; +// } +// return new NotTypePattern(negated); + // AMC - the only safe thing to return here is maybe... + // see for example pr114054 + return MAYBE; } public Object visit(ThisOrTargetAnnotationPointcut node, Object data) { -- cgit v1.2.3