Fixing another bug for getGenericReturnType so that it recognizes Class<?> as Wildcar...
authorRahmadi Trimananda <rtrimana@uci.edu>
Sat, 22 Jun 2019 18:23:44 +0000 (11:23 -0700)
committerRahmadi Trimananda <rtrimana@uci.edu>
Sat, 22 Jun 2019 18:23:44 +0000 (11:23 -0700)
examples/Reflection.java
src/main/gov/nasa/jpf/vm/ClassInfo.java
src/main/gov/nasa/jpf/vm/MethodInfo.java

index 2c90e54d52af940d2a34e3ac065e497d8dfcf5ad..568743683d21f3a328d748972ebcaacaa1fbc603 100644 (file)
@@ -24,11 +24,13 @@ 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, 
+                       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,10 +72,10 @@ public class Reflection {
             System.out.println(interfaces[i]);
         }*/
       
-      Method[] methods = Class.class.getMethods();
+      Method[] methods = SampleClass.class.getMethods();
         Method method = null;
         for(Method mth : methods) {
-            if (mth.getName().equals("isAssignableFrom")) {
+            if (mth.getName().equals("setSampleField")) {
                 method = mth;
             }
         }
@@ -101,10 +103,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);
-         */
+         
    }
 }
 
index eaaa3d01b2fddab8291709213d92452469d40636..abc9499818e31ba264210cfbfdf7dd9341e178b9 100644 (file)
@@ -2601,9 +2601,7 @@ public class ClassInfo extends InfoObject implements Iterable<MethodInfo>, Gener
 
   // TODO: Fix for Groovy's model-checking
   public String[] getGenericTypeVariableNames () {
-    // TODO: We need to double check but for some reason Groovy has a type of generic signature with "<*>"
-    // TODO: in the class file.
-    if (genericSignature == null || genericSignature.equals("") || genericSignature.contains("<*>"))
+    if (genericSignature == null || genericSignature.equals(""))
       return new String[0];
     if (!genericSignature.contains(":"))
       return new String[0];
index 428301c545e3c7f2ec0fb206d582f620017e9e82..367f584dadbce68e3cdc102de1c0be45dd5659fd 100644 (file)
@@ -505,8 +505,6 @@ public class MethodInfo extends InfoObject implements GenericSignatureHolder  {
 
   // TODO: Fix for Groovy's model-checking
   public String[] getArgumentGenericTypeNames () {
-    // TODO: We need to double check but for some reason Groovy has a type of generic signature with "<*>"
-    // TODO: in the class file.
     if (genericSignature == null || genericSignature.equals(""))
       return getArgumentTypeNames();
     // We need to first find the start of the method parameters in the signature
@@ -592,9 +590,7 @@ public class MethodInfo extends InfoObject implements GenericSignatureHolder  {
   }
 
   public String getGenericReturnTypeName () {
-    // TODO: We need to double check but for some reason Groovy has a type of generic signature with "<*>"
-    // TODO: in the class file.
-    if (genericSignature == null || genericSignature.equals("") || genericSignature.contains("<*>"))
+    if (genericSignature == null || genericSignature.equals(""))
       return Types.getReturnTypeName(signature);
     return Types.getGenericReturnTypeName(genericSignature);
   }