More filtering: never define a method call 'call' since Groovy generates a lot of...
[jpf-core.git] / src / main / gov / nasa / jpf / vm / serialize / SmartThingsConfig.java
index dcfa11c2c85d95412b5542aabc463dbfc19dc588..589f53eee0f1bba68fc0fcf6cfc4a8db033c08a5 100644 (file)
@@ -31,16 +31,108 @@ import gov.nasa.jpf.vm.serialize.AmmendableFilterConfiguration.FrameAmmendment;
 public class SmartThingsConfig
   implements FieldAmmendment, FrameAmmendment {
 
-  boolean ignoreClass(ClassInfo ci) {
-    String pName = ci.getPackageName();
-    if (pName.startsWith("org.codehaus.groovy")) {
-      //      System.out.println("Ignoring "+pName);
+  public boolean staticClass(ClassInfo ci) {
+    String pName = ci.getName();
+    if (pName.startsWith("java."))
       return true;
+
+    if (pName.startsWith("sun."))
+      return true;
+
+    if (pName.startsWith("com.sun"))
+      return true;
+
+    if (pName.startsWith("org."))
+      return true;
+
+    if (pName.startsWith("groovy."))
+      return true;
+
+    if (pName.startsWith("groovyjarjarasm."))
+      return true;
+
+    if (pName.startsWith("gov."))
+      return true;
+
+    if (pName.startsWith("["))
+      return true;
+
+    return false;
+  }
+  public boolean ignoreClass(ClassInfo ci) {
+    String pName = ci.getName();
+    if (pName.startsWith("org")) {
+      if (pName.startsWith("org.codehaus.groovy")) {
+        //      System.out.println("Ignoring "+pName);
+        return true;
+      }
+      if (pName.startsWith("org.apache.groovy")) {
+        //      System.out.println("Ignoring "+pName);
+        return true;
+      }
+    } else if (pName.startsWith("java")) {
+      if (pName.startsWith("java.lang")) {
+        if (pName.startsWith("java.lang.reflect")) {
+          return true;
+        }
+        if (pName.startsWith("java.lang.ref")) {
+          return true;
+        }
+        if (pName.startsWith("java.lang.ClassLoader")) {
+          return true;
+        }
+        if (pName.startsWith("java.lang.Class"))
+          return true;
+        if (pName.startsWith("java.lang.Thread"))
+          return true;
+        if (pName.startsWith("java.lang.Package"))
+          return true;
+      } else {
+      if (pName.startsWith("java.util.concurrent")) {
+        //      System.out.println("Ignoring "+pName);
+        return true;
+      }
+      if (pName.startsWith("java.util.logging")) {
+        //      System.out.println("Ignoring "+pName);
+        return true;
+      }
+      if (pName.startsWith("java.beans")) {
+        return true;
+      }
+      if (pName.startsWith("java.io.OutputStreamWriter"))
+        return true;
+      if (pName.startsWith("java.io.PrintStream"))
+        return true;
+      if (pName.startsWith("java.io.BufferedWriter"))
+        return true;
+      }
+      if (pName.startsWith("java.nio.charset"))
+        return true;
+      
+    } else if (pName.startsWith("groovy")) {
+      if (pName.startsWith("groovy.lang")) {
+        //      System.out.println("Ignoring "+pName);
+        return true;
+      }
+      if (pName.startsWith("groovyjarjarasm.asm")) {
+        //      System.out.println("Ignoring "+pName);
+        return true;
+      }
     }
-    if (pName.startsWith("groovy.lang")) {
-      //      System.out.println("Ignoring "+pName);
+    if (pName.startsWith("com.sun.beans")) {
       return true;
     }
+    if (pName.startsWith("sun.reflect")) {
+      return true;
+    }
+    if (pName.startsWith("sun.misc.SharedSecrets"))
+      return true;
+    if (pName.startsWith("sun.util.logging"))
+      return true;
+    if (pName.startsWith("sun.net.www"))
+      return true;
+    if (pName.startsWith("gov.nasa"))
+      return true;
     return false;
   }
   
@@ -49,17 +141,27 @@ public class SmartThingsConfig
     ClassInfo ci = fi.getClassInfo();
     if (ignoreClass(ci))
       return POLICY_IGNORE;
-    
+    ClassInfo civ = fi.getTypeClassInfo();
+    if (ignoreClass(civ))
+      return POLICY_IGNORE;      
     return sofar;
   }
 
+  boolean checkName(String name) {
+    if (name.equals("call"))
+      return true;
+    return (name.charAt(0) == '[' && name.charAt(name.length()-1)==']');
+  }
+  
   @Override
   public FramePolicy ammendFramePolicy(MethodInfo mi, FramePolicy sofar) {
     ClassInfo ci = mi.getClassInfo();
-    if (ignoreClass(ci)) {
+    if (ignoreClass(ci) || checkName(mi.getName())) {
       sofar.includeLocals = false;
       sofar.includeOps = false;
       sofar.includePC = false;
+    } else {
+      //            System.out.println("Including M: " +mi.getName());
     }
 
     return sofar;