summaryrefslogtreecommitdiffstats
path: root/tests/bugs160
diff options
context:
space:
mode:
authoraclement <aclement>2008-02-19 22:01:34 +0000
committeraclement <aclement>2008-02-19 22:01:34 +0000
commitb91e3abfe2d9fcafac1eabaefab0f1c3ba8ae55a (patch)
tree60d40a96b0cbc61d888867ab0784723c87a3a5e2 /tests/bugs160
parent876e7d62bb8cd5313377adaf02db372a1e539b82 (diff)
downloadaspectj-b91e3abfe2d9fcafac1eabaefab0f1c3ba8ae55a.tar.gz
aspectj-b91e3abfe2d9fcafac1eabaefab0f1c3ba8ae55a.zip
204505: testcode and fix: poorly documented method in ResolvedMemberImpl now creates a sig based on the erasure of the type variable rather than using the type variable itself. Passes this case but could be related situations that fail...
Diffstat (limited to 'tests/bugs160')
-rw-r--r--tests/bugs160/pr204505/Bug.java16
-rw-r--r--tests/bugs160/pr204505/GenericInterfaceWithGenericArgumentPointcutBug.java88
2 files changed, 104 insertions, 0 deletions
diff --git a/tests/bugs160/pr204505/Bug.java b/tests/bugs160/pr204505/Bug.java
new file mode 100644
index 000000000..e1e1ec55e
--- /dev/null
+++ b/tests/bugs160/pr204505/Bug.java
@@ -0,0 +1,16 @@
+import java.util.*;
+
+interface GenericIFace<B> {
+ public void save(B bean);
+ public void saveAll(Collection<B> beans);
+}
+
+class C<A> implements GenericIFace<A> {
+ public void save(A bean) {}
+ public void saveAll(Collection<A> bean) {}
+}
+
+aspect X {
+ before(): execution(* GenericIFace.save*(..)) { }
+// before(): execution(* GenericIFace+.save*(..)) { }
+}
diff --git a/tests/bugs160/pr204505/GenericInterfaceWithGenericArgumentPointcutBug.java b/tests/bugs160/pr204505/GenericInterfaceWithGenericArgumentPointcutBug.java
new file mode 100644
index 000000000..f355eb6ee
--- /dev/null
+++ b/tests/bugs160/pr204505/GenericInterfaceWithGenericArgumentPointcutBug.java
@@ -0,0 +1,88 @@
+package mypackage;
+
+import java.util.Collection;
+import junit.framework.TestCase;
+
+/**
+ * A test case depicting the scenario where a parameterized interface includes a method
+ * that takes a parameterized object. A interface-based pointcut (that does not include
+ * '+') fails to select such a method.
+ *
+ * @author Ramnivas Laddad
+ *
+ */
+public class GenericInterfaceWithGenericArgumentPointcutBug extends TestCase {
+ private GenericInterface<String> testObject = new GenericImpl<String>();
+
+ public static void main(String[] args) throws Exception {
+ GenericInterfaceWithGenericArgumentPointcutBug instance = new GenericInterfaceWithGenericArgumentPointcutBug();
+ instance.setUp();
+ instance.testGenericInterfaceGenericArgExecution();
+ instance.setUp();
+ instance.testGenericInterfaceNonGenericArgExecution();
+ instance.setUp();
+ instance.testgenericInterfaceSubtypeGenericArgExecution();
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ TestAspect.aspectOf().genericInterfaceNonGenericArgExecutionCount = 0;
+ TestAspect.aspectOf().genericInterfaceGenericArgExecutionCount = 0;
+ TestAspect.aspectOf().genericInterfaceSubtypeGenericArgExecutionCount = 0;
+ }
+
+ public void testGenericInterfaceNonGenericArgExecution() {
+ testObject.save("");
+ assertEquals(1, TestAspect.aspectOf().genericInterfaceNonGenericArgExecutionCount);
+ }
+
+ public void testGenericInterfaceGenericArgExecution() {
+ testObject.saveAll(null);
+ assertEquals(1, TestAspect.aspectOf().genericInterfaceGenericArgExecutionCount);
+ }
+
+ public void testgenericInterfaceSubtypeGenericArgExecution() {
+ testObject.saveAll(null);
+ assertEquals(1, TestAspect.aspectOf().genericInterfaceSubtypeGenericArgExecutionCount);
+ }
+
+ static interface GenericInterface<T> {
+ public void save(T bean);
+ public void saveAll(Collection<T> beans);
+ }
+
+ static class GenericImpl<T> implements GenericInterface<T> {
+ public void save(T bean) {}
+ public void saveAll(Collection<T> beans) {}
+ }
+
+ static aspect TestAspect {
+ int genericInterfaceNonGenericArgExecutionCount;
+ int genericInterfaceGenericArgExecutionCount;
+ int genericInterfaceSubtypeGenericArgExecutionCount;
+
+ pointcut genericInterfaceNonGenericArgExecution()
+ : execution(* GenericInterface.save(..));
+
+ pointcut genericInterfaceGenericArgExecution()
+ : execution(* GenericInterface.saveAll(..));
+
+ pointcut genericInterfaceSubtypeGenericArgExecution()
+ : execution(* GenericInterface+.saveAll(..));
+
+ before() : genericInterfaceNonGenericArgExecution() {
+ genericInterfaceNonGenericArgExecutionCount++;
+ }
+
+ before() : genericInterfaceGenericArgExecution() {
+ genericInterfaceGenericArgExecutionCount++;
+ }
+
+ before() : genericInterfaceSubtypeGenericArgExecution() {
+ genericInterfaceSubtypeGenericArgExecutionCount++;
+ }
+ }
+}
+
+
+