From 8a34d98b678b9d85657d81b8991928b8b2788d05 Mon Sep 17 00:00:00 2001 From: avasseur Date: Thu, 29 Sep 2005 14:29:43 +0000 Subject: [PATCH] #108488 @AspectJ perthis(..) was broken for some pointcut issue checks for @AfterXX fixed --- .../ast/ValidateAtAspectJAnnotationsVisitor.java | 12 ++---------- tests/java5/ataspectj/ataspectj/PerClauseTest.java | 6 +++--- .../systemtest/ajc150/ataspectj/AtAjSyntaxTests.java | 3 +-- .../patterns/PerThisOrTargetPointcutVisitor.java | 3 ++- .../weaver/patterns/ThisOrTargetPointcut.java | 2 +- .../org/aspectj/weaver/patterns/WildTypePattern.java | 3 ++- 6 files changed, 11 insertions(+), 18 deletions(-) diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java index 3bec1549f..7aae00ecd 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java @@ -307,13 +307,9 @@ public class ValidateAtAspectJAnnotationsVisitor extends ASTVisitor { String thrownFormal = getStringLiteralFor("throwing",ajAnnotations.adviceAnnotation,throwingLocation); if (thrownFormal != null) { Argument[] arguments = methodDeclaration.arguments; - if (methodDeclaration.arguments != null - && !toArgumentNames(methodDeclaration.arguments).contains(thrownFormal)) { + if (!toArgumentNames(methodDeclaration.arguments).contains(thrownFormal)) { methodDeclaration.scope.problemReporter() .signalError(methodDeclaration.sourceStart,methodDeclaration.sourceEnd,"throwing formal '" + thrownFormal + "' must be declared as a parameter in the advice signature"); - } else { - methodDeclaration.scope.problemReporter() - .signalError(methodDeclaration.sourceStart,methodDeclaration.sourceEnd,"throwing formal '" + thrownFormal + "' must be declared as a parameter in the advice signature"); } } } @@ -322,13 +318,9 @@ public class ValidateAtAspectJAnnotationsVisitor extends ASTVisitor { int[] throwingLocation = new int[2]; String returningFormal = getStringLiteralFor("returning",ajAnnotations.adviceAnnotation,throwingLocation); if (returningFormal != null) { - if (methodDeclaration.arguments.length > 0 - && !toArgumentNames(methodDeclaration.arguments).contains(returningFormal)) { + if (!toArgumentNames(methodDeclaration.arguments).contains(returningFormal)) { methodDeclaration.scope.problemReporter() .signalError(methodDeclaration.sourceStart,methodDeclaration.sourceEnd,"returning formal '" + returningFormal + "' must be declared as a parameter in the advice signature"); - } else { - methodDeclaration.scope.problemReporter() - .signalError(methodDeclaration.sourceStart,methodDeclaration.sourceEnd,"returning formal '" + returningFormal + "' must be declared as a parameter in the advice signature"); } } } diff --git a/tests/java5/ataspectj/ataspectj/PerClauseTest.java b/tests/java5/ataspectj/ataspectj/PerClauseTest.java index dfb529dcd..34d9fb5c9 100644 --- a/tests/java5/ataspectj/ataspectj/PerClauseTest.java +++ b/tests/java5/ataspectj/ataspectj/PerClauseTest.java @@ -62,7 +62,7 @@ public class PerClauseTest extends TestCase { log("perTarget"); } - public void xtestPerTarget() { + public void testPerTarget() { s_log = new StringBuffer(); perTarget(); assertEquals("AOP.perTarget perTarget ", s_log.toString()); @@ -121,7 +121,7 @@ public class PerClauseTest extends TestCase { log("perCflow"); } - public void xtestPerCflow() throws Throwable { + public void testPerCflow() throws Throwable { s_log = new StringBuffer(); // no aspect bound yet @@ -177,7 +177,7 @@ public class PerClauseTest extends TestCase { assertEquals(2, PerClauseTestAspects.TestAspectPerCflow.s_count); } - public void xtestPerTypeWithin() { + public void testPerTypeWithin() { assertTrue(Aspects.hasAspect(PerClauseTestAspects.TestAspectPTW.class, PTW1.class)); assertTrue(Aspects.hasAspect(PerClauseTestAspects.TestAspectPTW.class, PTW2.class)); assertFalse(Aspects.hasAspect(PerClauseTestAspects.TestAspectPTW.class, PTWNoMatch.class)); diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java index f4ea339e1..e4f883c66 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java @@ -77,9 +77,8 @@ public class AtAjSyntaxTests extends XMLBasedAjcTestCase { runTest("BindingTest no inline"); } - //FIXME AV 2005-09 - commented as perthis(this(Type)) fails for now as of #108488 public void testPerClause() { - //runTest("PerClause"); + runTest("PerClause"); } public void testAroundInlineMunger_XnoInline() { diff --git a/weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java b/weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java index 4cbc88248..42f1b2d4e 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java +++ b/weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java @@ -137,7 +137,8 @@ public class PerThisOrTargetPointcutVisitor extends IdentityPointcutVisitor { //pertarget(target(Foo)) => Foo+ for type pattern matching //perthis(this(Foo)) => Foo+ for type pattern matching // TODO AV - we do like a deep copy by parsing it again.. quite dirty, would need a clean deep copy - TypePattern copy = new PatternParser(node.getType().toString()).parseTypePattern(); + TypePattern copy = new PatternParser(node.getType().toString().replace('$', '.')).parseTypePattern(); + // TODO AV - see dirty replace from $ to . here as inner classes are with $ instead (#108488) copy.includeSubtypes = true; return copy; } else { diff --git a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java index f962cf4aa..7eb8ad276 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java @@ -93,7 +93,7 @@ public class ThisOrTargetPointcut extends NameBindingPointcut { UnresolvedType typeToMatch = isThis ? shadow.getThisType() : shadow.getTargetType(); //if (typeToMatch == ResolvedType.MISSING) return FuzzyBoolean.NO; - return type.matches(typeToMatch.resolve(shadow.getIWorld()), TypePattern.DYNAMIC); + return type.matches(typeToMatch.resolve(shadow.getIWorld()), TypePattern.DYNAMIC);//AVPT was DYNAMIC } public void write(DataOutputStream s) throws IOException { diff --git a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java index 34363d39b..2cea93d52 100644 --- a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java @@ -447,7 +447,8 @@ public class WildTypePattern extends TypePattern { */ public FuzzyBoolean matchesInstanceof(ResolvedType type) { //XXX hack to let unmatched types just silently remain so - if (maybeGetSimpleName() != null) return FuzzyBoolean.NO; + if (maybeGetSimpleName() != null) return + FuzzyBoolean.NO; type.getWorld().getMessageHandler().handleMessage( new Message("can't do instanceof matching on patterns with wildcards", -- 2.39.5