Fixing a bug: Map's parameterized type signature with wildcard was not handled properly.
[jpf-core.git] / src / main / gov / nasa / jpf / vm / Types.java
index ba71512c0b219217936e81a00cf803a0f7899476..981ac10df0fc4c917a6e0b17d031645559f4bb36 100644 (file)
@@ -1222,20 +1222,30 @@ public class Types {
     int pos = signature.indexOf('<', 0);
     if (pos == -1)
       return new String[0];
     int pos = signature.indexOf('<', 0);
     if (pos == -1)
       return new String[0];
+
+    pos = pos + 1;
     ArrayList<String> typeVarNames = new ArrayList<>();
 
     while (pos < signature.length()) {
       String typeVarName = "";
     ArrayList<String> typeVarNames = new ArrayList<>();
 
     while (pos < signature.length()) {
       String typeVarName = "";
+      // Try comma first
       int comma = signature.indexOf(',', pos);
       if (comma == -1) {
       int comma = signature.indexOf(',', pos);
       if (comma == -1) {
-        int closing = signature.lastIndexOf('>', signature.length());
-        typeVarName = signature.substring(pos + 1, closing);
-        pos = signature.length();
+        // If not comma then perhaps semicolon
+        int semicolon = signature.indexOf(';', pos);
+        if (semicolon == -1) {
+          int closing = signature.lastIndexOf('>', signature.length());
+          typeVarName = signature.substring(pos, closing);
+          pos = signature.length();
+        } else {
+          typeVarName = signature.substring(pos, semicolon);
+          pos = semicolon + 1;
+        }
       } else {
       } else {
-        typeVarName = signature.substring(pos + 1, comma);
+        typeVarName = signature.substring(pos, comma);
         pos = comma + 1;
       }
         pos = comma + 1;
       }
-      typeVarNames.add(typeVarName);
+      typeVarNames.add(typeVarName.trim());
     }
 
     String[] arrTypeVarNames = new String[typeVarNames.size()];
     }
 
     String[] arrTypeVarNames = new String[typeVarNames.size()];