]> source.dussan.org Git - aspectj.git/commitdiff
211146: testcode: generics info lost from itds
authoraclement <aclement>
Thu, 21 Aug 2008 23:08:04 +0000 (23:08 +0000)
committeraclement <aclement>
Thu, 21 Aug 2008 23:08:04 +0000 (23:08 +0000)
tests/bugs162/pr211146/GenericsLost.java [new file with mode: 0644]
tests/bugs162/pr211146/GenericsLost2.java [new file with mode: 0644]
tests/bugs162/pr211146/GenericsLost2Dep.java [new file with mode: 0644]
tests/bugs162/pr211146/GenericsLost3.java [new file with mode: 0644]
tests/bugs162/pr211146/GenericsLost4.java [new file with mode: 0644]
tests/bugs162/pr211146/GenericsLost5.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc162/Ajc162Tests.java
tests/src/org/aspectj/systemtest/ajc162/ajc162.xml

diff --git a/tests/bugs162/pr211146/GenericsLost.java b/tests/bugs162/pr211146/GenericsLost.java
new file mode 100644 (file)
index 0000000..63631af
--- /dev/null
@@ -0,0 +1,23 @@
+import java.util.*;
+import java.lang.reflect.*;
+
+aspect Foo {
+
+   public List<String> Goo.getStrings() {
+     return null;
+   }
+   
+}
+
+class Goo {
+}
+       
+public class GenericsLost {
+
+          public static void main(String[]argv) throws Exception {
+                  Method m = Goo.class.getDeclaredMethod("getStrings");
+                  Type t = m.getGenericReturnType();
+                  if (!t.toString().equals("java.util.List<java.lang.String>")) 
+                          throw new RuntimeException("Incorrect signature. Signature is "+t);
+          }
+}
diff --git a/tests/bugs162/pr211146/GenericsLost2.java b/tests/bugs162/pr211146/GenericsLost2.java
new file mode 100644 (file)
index 0000000..1fc1b15
--- /dev/null
@@ -0,0 +1,13 @@
+import java.util.*;
+import java.lang.reflect.*;
+
+aspect Foo {
+
+   public List<String> GenericsLost2.getStrings() {
+     return null;
+   }
+}
+
+class GenericsLost2 {
+}
+       
\ No newline at end of file
diff --git a/tests/bugs162/pr211146/GenericsLost2Dep.java b/tests/bugs162/pr211146/GenericsLost2Dep.java
new file mode 100644 (file)
index 0000000..71b194a
--- /dev/null
@@ -0,0 +1,8 @@
+import java.util.*;
+import java.lang.reflect.*;
+
+public class GenericsLost2Dep {
+       public static void main(String[] args) {
+               new GenericsLost2().getStrings().add("abc");
+       }
+}
\ No newline at end of file
diff --git a/tests/bugs162/pr211146/GenericsLost3.java b/tests/bugs162/pr211146/GenericsLost3.java
new file mode 100644 (file)
index 0000000..e52ba8c
--- /dev/null
@@ -0,0 +1,79 @@
+import java.util.*;
+import java.lang.reflect.*;
+
+aspect Foo {
+
+   // return type
+   public List<String> Goo.getStrings() {
+     return null;
+   }
+   
+   // parameters
+   public void Goo.putStrings(List<String> ls, List<Integer> lls) {
+          
+   }
+   
+   // type variables
+   public <T extends Number> List<T> Goo.numerics(T t) {
+          return null;
+   }
+
+   // type variables 2
+   public <T extends List<String>> List<T> Goo.nightmare(T t) {
+          return null;
+   }
+
+   // type variables 3
+   public <T extends List<Q>,Q extends Number> List<T> Goo.holyCow(Q t) {
+          return null;
+   }
+}
+
+class Goo {
+}
+       
+public class GenericsLost3 {
+
+          public static void main(String[]argv) throws Exception {
+                  Method m = Goo.class.getDeclaredMethod("getStrings");
+                  Type t = m.getGenericReturnType();
+                  if (!t.toString().equals("java.util.List<java.lang.String>")) 
+                          throw new RuntimeException("Incorrect signature1. Signature is "+t);
+                  
+
+                  m = Goo.class.getDeclaredMethod("putStrings",new Class[]{List.class,List.class});
+                  Type[] ps = m.getGenericParameterTypes();
+                  if (!ps[0].toString().equals("java.util.List<java.lang.String>")) 
+                          throw new RuntimeException("Incorrect signature2. Signature is "+t);
+                  if (!ps[1].toString().equals("java.util.List<java.lang.Integer>")) 
+                          throw new RuntimeException("Incorrect signature3. Signature is "+t);
+                  
+
+                  m = Goo.class.getDeclaredMethod("numerics", new Class[]{Number.class});
+                  t = m.getGenericReturnType();
+                  if (!t.toString().equals("java.util.List<T>")) 
+                          throw new RuntimeException("Incorrect signature4. Signature is "+t);
+                  t = m.getGenericParameterTypes()[0];
+                  if (!t.toString().equals("T")) 
+                          throw new RuntimeException("Incorrect signature5. Signature is "+t);
+
+                  m = Goo.class.getDeclaredMethod("nightmare", new Class[]{List.class});
+                  t = m.getGenericReturnType();
+                  if (!t.toString().equals("java.util.List<T>")) 
+                          throw new RuntimeException("Incorrect signature4. Signature is "+t);
+                  t = m.getGenericParameterTypes()[0];
+                  if (!t.toString().equals("T")) 
+                          throw new RuntimeException("Incorrect signature5. Signature is "+t);
+                  
+
+                  m = Goo.class.getDeclaredMethod("holyCow", new Class[]{Number.class});
+                  t = m.getGenericReturnType();
+                  if (!t.toString().equals("java.util.List<T>")) 
+                          throw new RuntimeException("Incorrect signature4. Signature is "+t);
+                  t = m.getGenericParameterTypes()[0];
+                  if (!t.toString().equals("Q")) 
+                          throw new RuntimeException("Incorrect signature5. Signature is "+t);
+                  
+
+          }
+}
diff --git a/tests/bugs162/pr211146/GenericsLost4.java b/tests/bugs162/pr211146/GenericsLost4.java
new file mode 100644 (file)
index 0000000..2cdf76d
--- /dev/null
@@ -0,0 +1,28 @@
+import java.util.*;
+import java.lang.reflect.*;
+
+// interface ITD
+aspect Foo {
+   public List<String> IFace.getStrings() {
+     return null;
+   }
+}
+
+interface IFace {}
+
+class Goo implements IFace {}
+
+public class GenericsLost4 {
+   public static void main(String[]argv) throws Exception {
+          Method m = Goo.class.getDeclaredMethod("getStrings");
+          Type t = m.getGenericReturnType();
+          if (!t.toString().equals("java.util.List<java.lang.String>")) 
+                  throw new RuntimeException("Incorrect signature. Signature is "+t);
+
+          m = IFace.class.getDeclaredMethod("getStrings");
+          t = m.getGenericReturnType();
+          if (!t.toString().equals("java.util.List<java.lang.String>")) 
+                  throw new RuntimeException("Incorrect signature. Signature is "+t);
+   }
+}
+       
\ No newline at end of file
diff --git a/tests/bugs162/pr211146/GenericsLost5.java b/tests/bugs162/pr211146/GenericsLost5.java
new file mode 100644 (file)
index 0000000..329bdd7
--- /dev/null
@@ -0,0 +1,19 @@
+import java.util.*;
+import java.lang.reflect.*;
+
+// generic field itd
+aspect Foo {
+   public List<String> Goo.ls;
+}
+
+class Goo {}
+
+public class GenericsLost5 {
+   public static void main(String[]argv) throws Exception {
+          Field f = Goo.class.getDeclaredField("ls");
+          Type t = f.getGenericType();
+          if (!t.toString().equals("java.util.List<java.lang.String>")) 
+                  throw new RuntimeException("Incorrect signature. Signature is "+t);
+   }
+}
+       
\ No newline at end of file
index 7b06234bc423bc3f021864aae2fe0a91dc267ce4..970d65219d469dad95a82c3b8b537dd2f4319c38 100644 (file)
@@ -19,6 +19,11 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
 public class Ajc162Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
        
        // AspectJ1.6.2 
+       public void testLostGenericsSigOnItd_pr211146() { runTest("lost generic sig on itd"); }
+       public void testLostGenericsSigOnItd_pr211146_2() { runTest("lost generic sig on itd - 2"); }
+       public void testLostGenericsSigOnItd_pr211146_3() { runTest("lost generic sig on itd - 3"); }
+       public void testLostGenericsSigOnItd_pr211146_4() { runTest("lost generic sig on itd - 4"); }
+       public void testLostGenericsSigOnItd_pr211146_5() { runTest("lost generic sig on itd - 5"); }
        public void testMissingContext_pr194429() { runTest("missing context"); }
        public void testWarningsForLimitations_pr210114() { runTest("warnings for limitations"); }
        public void testPTW_pr244830() { runTest("ptw initFailureCause"); }
index 1b3cfed020a5ab5f8d315416ae69532ed5d5e300..8af63770001d78d6194182bece71814f6ca455ad 100644 (file)
@@ -3,6 +3,31 @@
 <!-- AspectJ v1.6.2 Tests -->
 <suite>
 
+       <ajc-test dir="bugs162/pr211146" title="lost generic sig on itd">
+         <compile files="GenericsLost.java" options="-1.5"/>
+         <run class="GenericsLost"/>
+       </ajc-test>
+       
+       <ajc-test dir="bugs162/pr211146" title="lost generic sig on itd - 2">
+         <compile files="GenericsLost2.java" outjar="code.jar" options="-1.5"/>
+         <compile files="GenericsLost2Dep.java" classpath="$sandbox/code.jar" options="-1.5"/>
+       </ajc-test>
+       
+       <ajc-test dir="bugs162/pr211146" title="lost generic sig on itd - 3">
+         <compile files="GenericsLost3.java" options="-1.5"/>
+         <run class="GenericsLost3"/>
+       </ajc-test>
+       
+       <ajc-test dir="bugs162/pr211146" title="lost generic sig on itd - 4">
+         <compile files="GenericsLost4.java" options="-1.5"/>
+         <run class="GenericsLost4"/>
+       </ajc-test>
+       
+       <ajc-test dir="bugs162/pr211146" title="lost generic sig on itd - 5">
+         <compile files="GenericsLost5.java" options="-1.5"/>
+         <run class="GenericsLost5"/>
+       </ajc-test>
+       
        <ajc-test dir="bugs162/pr194429" title="missing context">
          <compile files="A.java" options="-1.5">
            <message kind="error" line="14" text="incompatible type, expected java.util.Set found BindingTypePattern("/>