Adding ParameterizedTypeImpl to getGenericSuperclass method.
[jpf-core.git] / examples / Reflection.java
index 88f41d555257c6e0fbae9fe898f9225fb289d3b8..d8f6e44a742d498236b5627405e938167caab8cc 100644 (file)
@@ -12,14 +12,14 @@ public class Reflection {
        class GenericShort<TUVW,ABCD> {
        }
 
-       class Generic<TUVW,ABCD,KLM,NOP> {
+       class Generic<TUVW,ABCD,KLM,NOP> extends GenericShort<TUVW,ABCD> {
        
        }
 
-       class SampleClass {
+       class SampleClass<VWXZ> {
           private String sampleField;
 
-          public Generic<Integer,String,Double,Short> setSampleField(List<String> listString, Map<Integer,String> mapString,
+          public Generic<Integer,String,Double,Short> setSampleField(Class<VWXZ> clazz, List<String> listString, Map<Integer,String> mapString,
                                Generic<Integer,String,Double,Short> test,
                                String sampleField, int one, short two, double three, Object obj) {
                  this.sampleField = sampleField; 
@@ -42,30 +42,45 @@ public class Reflection {
 
    public static void main(String[] args) {
 
-      Method[] methods = SampleClass.class.getMethods();
-      Type[] parameters = methods[0].getGenericParameterTypes();
+      /*Method[] methods = SampleClass.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();
+      System.out.println();*/
+      Type superCls = Generic.class.getGenericSuperclass();
+      //Type superCls = String.class.getGenericSuperclass();
+      System.out.println(superCls);
       /*Class[] parameterTypes = methods[0].getParameterTypes();
       for(Class parameterType: parameterTypes){
          System.out.println(parameterType.getName());   
  
       }
       System.out.println();*/
-      TypeVariable[] typeParameters = Generic.class.getTypeParameters();
+      /*TypeVariable[] typeParameters = Generic.class.getTypeParameters();
       //TypeVariable[] typeParameters = SampleClass.class.getTypeParameters();
       for(TypeVariable typeVar: typeParameters){
          System.out.println(typeVar);   
  
       }
       System.out.println();
-      
+
+      Type[] bounds = typeParameters[0].getBounds();
+      for (Type bound : bounds) {
+          System.out.println(bound);
+      }
+      System.out.println();
       Type returnType = methods[0].getGenericReturnType();
       System.out.println(returnType);
-         
+         */
    }
 }