--- /dev/null
+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++;
+ }
+ }
+}
+
+
+
* These are tests for AspectJ1.6.0
*/
public class Ajc160Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
-
+
public void testBoundsCheckShouldFail_pr219298() { runTest("bounds check failure");}
public void testBoundsCheckShouldFail_pr219298_2() { runTest("bounds check failure - 2");}
+ public void testGenericMethodMatching_pr204505_1() { runTest("generics method matching - 1");}
+ public void testGenericMethodMatching_pr204505_2() { runTest("generics method matching - 2");}
public void testDecFieldProblem_pr218167() { runTest("dec field problem");}
public void testGenericsSuperITD_pr206911() { runTest("generics super itd"); }
public void testGenericsSuperITD_pr206911_2() { runTest("generics super itd - 2"); }
<!-- AspectJ v1.6.0 Tests -->
<suite>
+ <ajc-test dir="bugs160/pr204505" title="generics method matching - 1">
+ <compile options="-1.5 -showWeaveInfo" files="Bug.java">
+ <message kind="weave" text="execution(void C.save(java.lang.Object))"/>
+ <message kind="weave" text="execution(void C.saveAll(java.util.Collection))"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="bugs160/pr204505" title="generics method matching - 2">
+ <compile options="-1.5" files="GenericInterfaceWithGenericArgumentPointcutBug.java"/>
+ <run class="mypackage.GenericInterfaceWithGenericArgumentPointcutBug"/>
+ </ajc-test>
+
<ajc-test dir="bugs160/pr219298" title="bounds check failure">
<compile options="-1.5" files="TestMarkers.java">
<message kind="error" line="11" text="Bound mismatch: The type TestMarkers.SubGenericsType is not a valid substitute for the bounded"/>