]> source.dussan.org Git - aspectj.git/commitdiff
test for 114343 (see comment #5): another potential case
authoraclement <aclement>
Thu, 3 Nov 2005 11:05:52 +0000 (11:05 +0000)
committeraclement <aclement>
Thu, 3 Nov 2005 11:05:52 +0000 (11:05 +0000)
tests/bugs150/pr114343/case3/TTT.java [new file with mode: 0644]
tests/bugs150/pr114343/case3/Test.java [new file with mode: 0644]
tests/bugs150/pr114343/case3/TestAspect.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml

diff --git a/tests/bugs150/pr114343/case3/TTT.java b/tests/bugs150/pr114343/case3/TTT.java
new file mode 100644 (file)
index 0000000..c822a1c
--- /dev/null
@@ -0,0 +1,20 @@
+import java.util.*;
+
+public class TTT {
+  public void foo() {
+    System.err.println("Creating Test<Integer> instance");
+    Test<Integer> mt = new Test<Integer>();
+    System.err.println("Calling toArray");
+    Integer[] arr = mt.toArray(new Integer[]{});
+    System.err.println("done");
+  }
+
+  public Integer getFirst() {
+    System.err.println("Creating Test<Integer> instance");
+    Test<Integer> mt = new Test<Integer>();
+    System.err.println("Calling getFirst");
+    Integer i = mt.getFirst();
+    System.err.println("done");
+    return i;
+  }
+}
diff --git a/tests/bugs150/pr114343/case3/Test.java b/tests/bugs150/pr114343/case3/Test.java
new file mode 100644 (file)
index 0000000..2634cd9
--- /dev/null
@@ -0,0 +1,16 @@
+import java.util.*;
+
+public class Test<T extends Number> {
+
+  Set<T> set = new HashSet<T>();
+  T t = null;
+
+  public <T> T[] toArray(T[] a) {
+    System.err.println("In toArray()");
+    return set.toArray(a);
+  }
+
+  public T getFirst() {
+    return t;
+  }
+}
diff --git a/tests/bugs150/pr114343/case3/TestAspect.java b/tests/bugs150/pr114343/case3/TestAspect.java
new file mode 100644 (file)
index 0000000..6d82c0f
--- /dev/null
@@ -0,0 +1,32 @@
+import java.util.*;
+
+public privileged aspect TestAspect {
+
+  pointcut TestToArray(Test mt) : target(mt) && !within(TestAspect);
+
+  pointcut getFirstExec(Test mt) :
+    execution(* getFirst(..)) && target(mt) && !within(TestAspect);
+
+
+  Object[] around(Test mt, Object[] objs) :
+    TestToArray(mt) && args(objs) &&
+    execution(Object[] Test.toArray(Object[])) {
+
+    System.err.println("In around advice");
+    objs = proceed(mt, objs);
+    return objs;
+  }
+
+  Object around(Test mt): getFirstExec(mt) {
+    System.err.println("around on getFirstExec(): running");
+    return proceed(mt);
+  }
+
+
+  public static void main(String[] argv) {
+     System.err.println("TestAspect.main: Calling foo");
+     new TTT().foo();   
+     Object o = new TTT().getFirst();   
+     System.err.println("TestAspect.main: done");
+  }
+}
index c3a77ad2ed67a9798852a27b1899a387b021a543..82de22113a35923a88fed1d0d76ad08bf0879c1a 100644 (file)
@@ -57,6 +57,7 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
   public void testMatthewsAspect_pr113947_2() { runTest("maws generic aspect - 2");}
   public void testFieldGet_pr114343()         { runTest("field-get, generics and around advice");}
   public void testFieldGet_pr114343_2()       { runTest("field-get, generics and around advice - 2");}
+  public void testFieldGet_pr114343_3()       { runTest("field-get, generics and around advice - 3");}
   public void testCaptureBinding_pr114744()   { runTest("capturebinding wildcard problem");}
   
   public void testBadDecp_pr110788_1() { runTest("bad generic decp - 1");}
index 8d10e7563b2c060b540b5f345f19a82c1a07566c..bd501640298e47ed2e051cd481da81f63c9d47d5 100644 (file)
       </run>
     </ajc-test>
     
+    <ajc-test dir="bugs150/pr114343/case3" title="field-get, generics and around advice - 3">
+      <compile files="Test.java,TTT.java,TestAspect.java" options="-1.5"/>
+      <run class="TestAspect">
+        <stderr>
+          <line text="TestAspect.main: Calling foo"/>
+          <line text="Creating Test&lt;Integer&gt; instance"/>
+          <line text="Calling toArray"/>
+          <line text="In around advice"/>
+          <line text="In toArray()"/>
+          <line text="done"/>
+          <line text="Creating Test&lt;Integer&gt; instance"/>
+          <line text="Calling getFirst"/>
+          <line text="around on getFirstExec(): running"/>
+          <line text="done"/>
+          <line text="TestAspect.main: done"/>
+        </stderr>
+      </run>
+    </ajc-test>
+    
     <ajc-test dir="bugs150/pr113947/case1" title="maws generic aspect - 1">
         <compile files="AbstractListSupport.java,AnotherItem.java,Item.java,LinkedList.java,LinkedListItem.java,ListItem.java,StringList.java" options="-1.5">
           <!-- the 'static ref' messages are a bit poor and ought to be eliminated... -->