diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WithincodePointcut.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WithincodePointcut.java index d758083090..9f4d55ae0a 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WithincodePointcut.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WithincodePointcut.java @@ -41,6 +41,8 @@ public class WithincodePointcut extends Pointcut { // these next two are needed for inlining of field initializers flags |= Shadow.ConstructorExecution.bit; flags |= Shadow.Initialization.bit; + // According to the documentation, method (and constructor) execution matches. + flags |= Shadow.MethodExecution.bit; matchedShadowKinds = flags; } diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/matcher/tools/CommonPointcutExpressionTests.java b/org.aspectj.matcher/src/test/java/org/aspectj/matcher/tools/CommonPointcutExpressionTests.java index 6ffea73a86..a4202633bd 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/matcher/tools/CommonPointcutExpressionTests.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/matcher/tools/CommonPointcutExpressionTests.java @@ -226,8 +226,8 @@ public void testMatchingWithinCode01() { ResolvedMember stringValueOfIntMethod = getMethod(jlString, "valueOf", "(I)Ljava/lang/String;"); ResolvedMember listAddMethod = getMethod(juList, "add", "(Ljava/lang/Object;)Z"); - assertTrue(ex.matchesMethodExecution(stringSplitMethod).neverMatches()); - assertTrue(ex.matchesMethodExecution(stringValueOfIntMethod).neverMatches()); + assertTrue(ex.matchesMethodExecution(stringSplitMethod).alwaysMatches()); + assertTrue(ex.matchesMethodExecution(stringValueOfIntMethod).alwaysMatches()); assertTrue(ex.matchesMethodExecution(listAddMethod).neverMatches()); } diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/PointcutRewriterTest.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/PointcutRewriterTest.java index 5342092efe..5d92043638 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/PointcutRewriterTest.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/PointcutRewriterTest.java @@ -337,7 +337,8 @@ public void testKindSetOfWithinCode() { Set matches = Shadow.toSet(p.couldMatchKinds()); for (Shadow.Kind o : matches) { assertFalse("No kinds that are themselves enclosing", - (o.isEnclosingKind() && o != Shadow.ConstructorExecution && o != Shadow.Initialization)); + (o.isEnclosingKind() && o != Shadow.ConstructorExecution && o != Shadow.Initialization + && o != Shadow.MethodExecution)); } for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) { if (!Shadow.SHADOW_KINDS[i].isEnclosingKind()) { @@ -346,6 +347,7 @@ public void testKindSetOfWithinCode() { } assertTrue("Need cons-exe for inlined field inits", matches.contains(Shadow.ConstructorExecution)); assertTrue("Need init for inlined field inits", matches.contains(Shadow.Initialization)); + assertTrue("Needs method-exe to comply with the docs", matches.contains(Shadow.MethodExecution)); // + @ p = getPointcut("@withincode(Foo)"); matches = Shadow.toSet(p.couldMatchKinds()); diff --git a/tests/bugs150/Pr103097.aj b/tests/bugs150/Pr103097.aj index e8e3cbb684..b6ea1dfdc1 100644 --- a/tests/bugs150/Pr103097.aj +++ b/tests/bugs150/Pr103097.aj @@ -3,7 +3,7 @@ import java.io.IOException; public aspect Pr103097 { declare soft: IOException: within(Pr103097) && - !withincode(* *(..)) && + (!withincode(* *(..)) || execution(* *(..))) && !call(* *(..)); before() : execution(* main(..)) { diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc150/ajc150.xml index 398e0032da..4cec5764b9 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc150/ajc150.xml @@ -5207,7 +5207,9 @@ + + @@ -5218,16 +5220,27 @@ + + + + + + + + + + + @@ -5445,7 +5458,9 @@ + + diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc152/synchronization.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc152/synchronization.xml index b3748c7ab9..2397f9a8cc 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc152/synchronization.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc152/synchronization.xml @@ -324,6 +324,7 @@ + diff --git a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutExpressionTest.java b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutExpressionTest.java index b4337e66aa..f44ba912b7 100644 --- a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutExpressionTest.java +++ b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutExpressionTest.java @@ -118,7 +118,7 @@ public void testMatchesMethodExecution() { // withincode ex = p.parsePointcutExpression("withincode(* a*(..))"); - assertTrue("Should not match", ex.matchesMethodExecution(a).neverMatches()); + assertTrue("Should match", ex.matchesMethodExecution(a).alwaysMatches()); } public void testMatchesConstructorCall() {