Fixing a bug: Map's parameterized type signature with wildcard was not handled properly.
[jpf-core.git] / examples / Reflection.java
index 9502a04564bb056d6b4c9950f7f0805a63eb1030..0918964c6fa547d29581b8c8518cffba5e5eefc9 100644 (file)
@@ -7,6 +7,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 
 import java.math.BigInteger;
 import java.security.ProtectionDomain;
@@ -50,39 +51,40 @@ public class Reflection {
                  return listString;
           }*/
        }
-       
-           private static int digitsPerInt[] = {0, 0, 30, 19, 15, 13, 11,
-            11, 10, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6,
-            6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5};
-                       
-               private static long bitsPerDigit[] = { 0, 0,
-            1024, 1624, 2048, 2378, 2648, 2875, 3072, 3247, 3402, 3543, 3672,
-            3790, 3899, 4001, 4096, 4186, 4271, 4350, 4426, 4498, 4567, 4633,
-            4696, 4756, 4814, 4870, 4923, 4975, 5025, 5074, 5120, 5166, 5210,
-            5253, 5295};
 
    public static void main(String[] args) {
+          
+         //BigInteger bi = new BigInteger("-1");
+         //System.out.println(bi);
+          
+         /* TODO: Enumerate all methods in Class.class */ 
+      Method[] methods = Collection.class.getMethods();
+      for(Method mth : methods) {
+                 System.out.println("===========================");
+         //System.out.println("Method: " + mth.getName());
+                 Type[] parameters = mth.getGenericParameterTypes();
+                 for (int i = 0; i < parameters.length; i++) {
+                    System.out.println(parameters[i]);
+                 }
+                 System.out.println();
+                 Type returnType = mth.getGenericReturnType();
+                 System.out.println(returnType + "\n");
+      }
 
-      /*Method[] methods = SampleClass.class.getMethods();
+      /*Method[] methods = Collection.class.getMethods();
       //  Method[] methods = Class.class.getMethods();
         Method method = null;
         for(Method meth : methods) {
-            if (meth.getName().equals("setSampleField")) {
-                method = meth;
-            }
-        }
-        Type[] parameters = method.getGenericParameterTypes();
-      //Type[] parameters = methods[0].getGenericParameterTypes();
-      for (int i = 0; i < parameters.length; i++) {
-         System.out.println(parameters[i]);
-      }
-      System.out.println();
-      Type returnType = method.getGenericReturnType();
-         Class.class.getSimpleName();*/
-      //System.out.println(returnType);
-         
-      //BigInteger bi = new BigInteger("-1");
-         //System.out.println(bi);
+                       System.out.println("===========================");
+                       //System.out.println("Method: " + meth.toString());
+                       Type[] parameters = meth.getGenericParameterTypes();
+                       for (int i = 0; i < parameters.length; i++) {
+                               System.out.println(parameters[i]);
+                       }
+                       Type returnType = meth.getGenericReturnType();
+                       System.out.println(returnType);
+                       System.out.println("===========================");
+        }*/
          
         /* TODO: This is an excerpt of the BigInteger library
                int radix = 10;
@@ -161,13 +163,14 @@ public class Reflection {
         }*/
       
       
-         /*Method[] methods = Class.class.getMethods();
+         /*Method[] methods = Map.class.getMethods();
          Method method = null;
       for(Method mth : methods) {
-        if (mth.getName().equals("getConstructor")) {
+        if (mth.getName().equals("putAll")) {
         //if (mth.getName().equals("isAssignableFrom")) {
         //if (mth.getName().equals("getSuperclass")) {
            method = mth;
+                  break;
         }
       }
       Type[] parameters = method.getGenericParameterTypes();
@@ -178,20 +181,6 @@ public class Reflection {
       System.out.println();
       Type returnType = method.getGenericReturnType();
       System.out.println(returnType);*/
-      
-      /* TODO: Enumerate all methods in Class.class */
-      /*Method[] methods = Class.class.getMethods();
-      for(Method mth : methods) {
-                 System.out.println("===========================");
-         System.out.println("Method: " + mth.getName());
-                 Type[] parameters = mth.getGenericParameterTypes();
-                 for (int i = 0; i < parameters.length; i++) {
-                    System.out.println(parameters[i]);
-                 }
-                 System.out.println();
-                 Type returnType = mth.getGenericReturnType();
-                 System.out.println(returnType + "\n");
-      }*/
 
       /*Class[] parameterTypes = methods[0].getParameterTypes();
       for(Class parameterType: parameterTypes){
@@ -213,8 +202,8 @@ public class Reflection {
       }
       System.out.println();*/
          
-         ProtectionDomain pd = Class.class.getProtectionDomain();
-      System.out.println(pd);
+         //ProtectionDomain pd = Class.class.getProtectionDomain();
+      //System.out.println(pd);
    }
 }