First attempt to add getGenericParameterTypes() and getGenericReturnType(); So far...
[jpf-core.git] / src / main / gov / nasa / jpf / vm / Types.java
index ee64f70a8a2ad9c735e44a20b6006288bdfc7aa4..c5b2f7f82d3cee8b4b4f843a4aaccd25d00687a2 100644 (file)
@@ -73,6 +73,9 @@ public class Types {
     return args;
   }
 
+  // TODO: Fix for Groovy's model-checking
+  // TODO: We return the generic type name whenever possible (the one between '<' and '>')
+  // TODO: To do this we fixed the implementation of getTypeLength
   public static String[] getArgumentTypeNames (String signature) {
     int len = signature.length();
 
@@ -95,7 +98,7 @@ public class Types {
     
     return typeNames;
   }
-  
+
   public static String dequalify (String typeName){
     int idx = typeName.lastIndexOf('.');
     if (idx > 0) {
@@ -585,6 +588,11 @@ public class Types {
     int i = signature.indexOf(')');
     return getTypeName(signature.substring(i+1));
   }
+
+  public static String getGenericReturnTypeName (String signature){
+    int i = signature.indexOf(')');
+    return getTypeName(signature.substring(i+1));
+  }
   
   public static String getTypeSignature (String type, boolean asDotNotation) {
     String  t = null;
@@ -906,9 +914,16 @@ public class Types {
 
     int len1 = len-1;
     if (signature.charAt(len1) == ';') {
-      return signature.substring(1, len1).replace('/', '.');
+      // TODO: Fix for Groovy's model-checking
+      // TODO: Cleaning up the generic type part inside '<' and '>'
+      return signature.substring(1, len1).replace('/', '.').
+              replaceAll(";L", ", ").
+              replace("<L","<").
+              replace(";>", ">");
     }
 
+
+
     throw new JPFException("invalid type string: " + signature);
   }
 
@@ -1091,6 +1106,15 @@ public class Types {
     case 'L':
 
       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;
+        }
+      }
 
       if (semicolon == -1) {
         throw new JPFException("invalid type signature: " +