From 27e68f3b3ae82408e8e046a40ab69d9e4996ff5a Mon Sep 17 00:00:00 2001 From: acolyer Date: Fri, 26 Aug 2005 11:43:32 +0000 Subject: [PATCH] tests for pr108050, signature matching in multiple override scenario --- tests/bugs150/pr108050.aj | 30 +++++++++++++++++++ .../systemtest/ajc150/Ajc150Tests.java | 4 +++ .../org/aspectj/systemtest/ajc150/ajc150.xml | 10 ++++++- .../aspectj/weaver/JoinPointSignature.java | 11 +++++++ .../aspectj/weaver/ResolvedMemberImpl.java | 6 ++-- 5 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 tests/bugs150/pr108050.aj diff --git a/tests/bugs150/pr108050.aj b/tests/bugs150/pr108050.aj new file mode 100644 index 000000000..5ad5d25cb --- /dev/null +++ b/tests/bugs150/pr108050.aj @@ -0,0 +1,30 @@ +class HttpServlet { + protected void doPost() { + } +} + +abstract class MockServlet extends HttpServlet { + protected void doPost() { + } + + private static aspect FindMatches { + declare warning: execution(* HttpServlet.do*(..)): "servlet request"; + } +} + +class MockDelayingServlet extends MockServlet { + private static final long serialVersionUID = 1; +} + +class MockServlet4 extends MockDelayingServlet +{ + protected void doPost() + { + } +} + + + + + + diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index d82a6b9ce..c442b9724 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -286,6 +286,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { runTest("multiple anonymous inner classes 2"); } + public void testSignatureMatchingInMultipleOverrideScenario() { + runTest("signature matching in override scenario"); + } + // helper methods..... public SyntheticRepository createRepos(File cpentry) { diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 99182a7e1..3cebcd13d 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -137,7 +137,15 @@ - + + + + + + + + + diff --git a/weaver/src/org/aspectj/weaver/JoinPointSignature.java b/weaver/src/org/aspectj/weaver/JoinPointSignature.java index d4276f9a6..97384c45f 100644 --- a/weaver/src/org/aspectj/weaver/JoinPointSignature.java +++ b/weaver/src/org/aspectj/weaver/JoinPointSignature.java @@ -371,4 +371,15 @@ public class JoinPointSignature implements ResolvedMember { realMember.resetReturnTypeToObjectArray(); } + public boolean equals(Object obj) { + if (! (obj instanceof JoinPointSignature)) return false; + JoinPointSignature other = (JoinPointSignature) obj; + if (!realMember.equals(other.realMember)) return false; + if (!substituteDeclaringType.equals(other.substituteDeclaringType)) return false; + return true; + } + + public int hashCode() { + return 17 + (37 * realMember.hashCode()) + (37 * substituteDeclaringType.hashCode()); + } } diff --git a/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java b/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java index e9dfa18ad..d94d3db12 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java +++ b/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java @@ -151,7 +151,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno accumulateTypesInBetween(originalDeclaringType, firstDefiningType, declaringTypes); - List memberSignatures = new ArrayList(); + Set memberSignatures = new HashSet(); for (Iterator iter = declaringTypes.iterator(); iter.hasNext();) { ResolvedType declaringType = (ResolvedType) iter.next(); ResolvedMember member = firstDefiningMember.withSubstituteDeclaringType(declaringType); @@ -204,7 +204,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno ResolvedMemberImpl memberToMatch, Iterator typesToLookIn, List typesAlreadyVisited, - List foundMembers) { + Set foundMembers) { while(typesToLookIn.hasNext()) { ResolvedType toLookIn = (ResolvedType) typesToLookIn.next(); if (!typesAlreadyVisited.contains(toLookIn)) { @@ -217,7 +217,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno accumulateTypesInBetween(toLookIn, resolvedDeclaringType, declaringTypes); for (Iterator iter = declaringTypes.iterator(); iter.hasNext();) { ResolvedType declaringType = (ResolvedType) iter.next(); - typesAlreadyVisited.add(declaringType); +// typesAlreadyVisited.add(declaringType); ResolvedMember member = foundMember.withSubstituteDeclaringType(declaringType); foundMembers.add(member); } -- 2.39.5