/**
  * This function instantiates an invariant class by using the <type>(PptSlice) constructor.
  *
  * @param theClass the invariant class to be instantiated
  * @param sl the PptSlice representing the variables about which an invariant is determined
  * @return an instance of the class in theClass if one can be constructed, else throw a
  *     RuntimeException
  */
 private static Invariant instantiateClass(Class<? extends Invariant> theClass, PptSlice sl) {
   try {
     Method get_proto = theClass.getMethod("get_proto", new Class<?>[] {});
     Invariant proto = (/*@Prototype*/ Invariant) get_proto.invoke(null, new Object[] {});
     Invariant inv = proto.instantiate(sl);
     return (inv);
   } catch (Exception e) {
     e.printStackTrace(System.out);
     throw new RuntimeException(
         "Error while instantiating invariant " + theClass.getName() + ": " + e.toString());
   }
 }
    /**
     * This function returns the check_modified method from the class type provided.
     *
     * @param theClass the class in which to find the check_modified method
     * @return the check_modified method if it exists
     * @throws RuntimeException if check_modified does not exist.
     */
    private static Method getCheckModified(Class<? extends Invariant> theClass) {
      Method[] methods = theClass.getMethods();

      Method currentMethod;
      for (int i = 0; i < methods.length; i++) {
        currentMethod = methods[i];
        if (currentMethod.getName().lastIndexOf("check_modified")
            != -1) { // Method should be called check_modified
          return currentMethod;
        }
      }
      throw new RuntimeException("Cannot find check_modified method");
    }
    /**
     * @return the method of invariant named by theClass that produces a String representation of
     *     the invariant.
     */
    private static Method getOutputProducer(Class<? extends Invariant> theClass) {
      Method[] methods = theClass.getMethods();

      Method currentMethod;
      for (int i = 0; i < methods.length; i++) {
        currentMethod = methods[i];

        // Method should be called format_using
        if (currentMethod.getName().lastIndexOf("format_using") != -1) {
          return currentMethod;
        }
      }
      throw new RuntimeException("Cannot find format_using method");
    }
 /**
  * @return a String representation of the invariantToTest. This String is produced by invoking
  *     the invariant's format_using with method with the argument OutputFormat.Daikon.
  */
 private static String getInvariantFormat() {
   try {
     return (String) outputProducer.invoke(invariantToTest, new Object[] {OutputFormat.DAIKON});
   } catch (Exception e) {
     throw new RuntimeException(invariantToTest + " " + outputProducer);
   }
 }
 /**
  * @return the InvariantStatus produced by invoking invariantToTest's check_modified method on
  *     the arguments represented by params.
  */
 private static InvariantStatus getCheckStatus(Object[] params) {
   try {
     return (InvariantStatus) checkModified.invoke(invariantToTest, params);
   } catch (Exception e) {
     throw new RuntimeException(" error in " + invariantToTest.getClass() + ": " + e);
   }
 }