/** * 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()); } }