Fixing getGenericReturnType to recognize the GenericArrayTypeImpl and ParameterizedTy...
[jpf-core.git] / examples / Reflection.java
index 2c90e54d52af940d2a34e3ac065e497d8dfcf5ad..b32715832912b6b30b60dc1e25510a89f5c6cb26 100644 (file)
@@ -24,11 +24,14 @@ public class Reflection {
     class SampleClass<VWXZ> {
         private String sampleField;
 
-        public Generic<Integer,String,Double,Short,Float> setSampleField(Class<?> clazz, List<String> listString, Map<Integer,String> mapString,
-                                                                         Generic<Integer,String,Double,Short,Float> test,
-                                                                         String sampleField, int one, short two, double three, Object obj) {
-            this.sampleField = sampleField;
-            return test;
+        public Class<?> setSampleField(Class<?> clazz,
+                       Class<? extends List> list, Class<? super Map> map,
+                       List<String> listString, Map<Integer,String> mapString, 
+                       Generic<Integer,String,Double,Short,Float> test, 
+                       String sampleField, int one, short two, double three, Object obj) {
+            
+                       this.sampleField = sampleField;
+            return clazz;
         }
                 
           
@@ -70,13 +73,15 @@ public class Reflection {
             System.out.println(interfaces[i]);
         }*/
       
-      Method[] methods = Class.class.getMethods();
-        Method method = null;
-        for(Method mth : methods) {
-            if (mth.getName().equals("isAssignableFrom")) {
-                method = mth;
-            }
+         Method[] methods = Class.class.getMethods();
+         Method method = null;
+      for(Method mth : methods) {
+        //if (mth.getName().equals("getConstructor")) {
+        //if (mth.getName().equals("isAssignableFrom")) {
+        if (mth.getName().equals("getTypeParameters")) {
+           method = mth;
         }
+      }
       Type[] parameters = method.getGenericParameterTypes();
       //Type[] parameters = methods[0].getGenericParameterTypes();
       for (int i = 0; i < parameters.length; i++) {
@@ -101,10 +106,10 @@ public class Reflection {
       for (Type bound : bounds) {
           System.out.println(bound);
       }
-      System.out.println();
-      Type returnType = methods[0].getGenericReturnType();
+      System.out.println();*/
+      Type returnType = method.getGenericReturnType();
       System.out.println(returnType);
-         */
+         
    }
 }