Fixing bug in recognizing Class<?> as a WilcardTypeImpl.
authorRahmadi Trimananda <rtrimana@uci.edu>
Sat, 22 Jun 2019 18:12:34 +0000 (11:12 -0700)
committerRahmadi Trimananda <rtrimana@uci.edu>
Sat, 22 Jun 2019 18:12:34 +0000 (11:12 -0700)
examples/Reflection.java
src/main/gov/nasa/jpf/vm/MethodInfo.java
src/main/gov/nasa/jpf/vm/Types.java

index bebd776c874bdd839e0329b36f32c8b7f673a92a..2c90e54d52af940d2a34e3ac065e497d8dfcf5ad 100644 (file)
@@ -24,13 +24,13 @@ public class Reflection {
     class SampleClass<VWXZ> {
         private String sampleField;
 
     class SampleClass<VWXZ> {
         private String sampleField;
 
-        public Generic<Integer,String,Double,Short,Float> setSampleField(Class<VWXZ> clazz, List<String> listString, Map<Integer,String> mapString,
+        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;
         }
                                                                          Generic<Integer,String,Double,Short,Float> test,
                                                                          String sampleField, int one, short two, double three, Object obj) {
             this.sampleField = sampleField;
             return test;
         }
-          
+                
           
           /*public String getSampleField() {
                  return sampleField;
           
           /*public String getSampleField() {
                  return sampleField;
@@ -73,7 +73,7 @@ public class Reflection {
       Method[] methods = Class.class.getMethods();
         Method method = null;
         for(Method mth : methods) {
       Method[] methods = Class.class.getMethods();
         Method method = null;
         for(Method mth : methods) {
-            if (mth.getName().equals("isAnnotationPresent")) {
+            if (mth.getName().equals("isAssignableFrom")) {
                 method = mth;
             }
         }
                 method = mth;
             }
         }
index 4176f686ee88b4339c8080f64be06016dfa8dad2..428301c545e3c7f2ec0fb206d582f620017e9e82 100644 (file)
@@ -507,7 +507,7 @@ public class MethodInfo extends InfoObject implements GenericSignatureHolder  {
   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.
   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("") || genericSignature.contains("<*>"))
+    if (genericSignature == null || genericSignature.equals(""))
       return getArgumentTypeNames();
     // We need to first find the start of the method parameters in the signature
     String methodParameters = genericSignature.substring(genericSignature.indexOf('('));
       return getArgumentTypeNames();
     // We need to first find the start of the method parameters in the signature
     String methodParameters = genericSignature.substring(genericSignature.indexOf('('));
index 948b42e512013b1b7cd88d2a0b002252e59dd8c3..61a17a88d6053e592cb327dd9e026f0ebecdf731 100644 (file)
@@ -1109,11 +1109,16 @@ public class Types {
       int semicolon = signature.indexOf(';', idx);
       // TODO: Fix for Groovy's model-checking
       // Check if this is a generic!
       int semicolon = signature.indexOf(';', idx);
       // TODO: Fix for Groovy's model-checking
       // Check if this is a generic!
-      if (signature.substring(idx,semicolon).indexOf('<') != -1) {
-        int generic = signature.indexOf('>', semicolon);
-        if (generic != -1) {
-          // Advance one character past the ';'
-          semicolon = generic + 1;
+      int genericStart = signature.substring(idx,semicolon).indexOf('<');
+      if (genericStart != -1) {
+        if (signature.charAt(genericStart + 2) == '*') {
+          semicolon = genericStart + 4;
+        } else {
+          int generic = signature.indexOf('>', semicolon);
+          if (generic != -1) {
+            // Advance one character past the ';'
+            semicolon = generic + 1;
+          }
         }
       }
 
         }
       }