@@ -0,0 +1,1761 @@
+%0Aimport org.junit.Assert.fail;%0A%0A@Contract( Serializable.class )%0Apublic class SerializableContractTest() %7B%0A%0A  private Serializable s;%0A  %0A  @Contract.Inject%0A  public void setSerializable( Serializable s )%0A  %7B%0A     this.s = s;%0A  %7D%0A  %0A  %0A  @Test%0A  public void testSerializableContract() %7B%0A%0A%09%09%09try %7B%0A%09%09%09%09Method m = clz.getDeclaredMethod(%22writeObject%22,%0A%09%09%09%09%09%09java.io.ObjectOutputStream.class);%0A%09%09%09%09if (!Modifier.isPrivate(m.getModifiers())) %7B%0A%09%09%09%09%09fail(String.format(%22writeObject in %25s is not private%22, s.getClass() ));%0A%09%09%09%09%7D%0A%09%09%09%09m = clz.getMethod(%22readObject%22, java.io.ObjectInputStream.class);%0A%09%09%09%09if (!Modifier.isPrivate(m.getModifiers())) %7B%0A%09%09%09%09%09fail( String.format(%22readObject in %25s is not private%22, s.getClass()));%0A%09%09%09%09%7D%0A%09%09%09%7D catch (NoSuchMethodException expected) %7B%0A%09%09%09%09for (Field fld : clz.getDeclaredFields()) %7B%0A%09%09%09%09%09if (!Modifier.isTransient(fld.getModifiers())%0A%09%09%09%09%09%09%09&& !Modifier.isStatic(fld.getModifiers())) %7B%0A%09%09%09%09%09%09Class%3C?%3E clazz = fld.getType();%0A%09%09%09%09%09%09// not serializable and not a collection%0A%09%09%09%09%09%09if (Collection.class.isAssignableFrom(clazz)) %7B%0A              // extract the class type from the collection%0A%09%09%09%09%09%09%09String sig = fld.toGenericString();%0A%09%09%09%09%09%09%09String%5B%5D parts = sig.split(%22%5B%5C%5C%3C%5C%5C%3E%5D%22);%0A%09%09%09%09%09%09%09if (parts.length == 3) %7B%0A%09%09%09%09%09%09%09%09try %7B%0A%09%09%09%09%09%09%09%09%09clazz = Class.forName(parts%5B1%5D);%0A%09%09%09%09%09%09%09%09%7D catch (ClassNotFoundException e) %7B%0A%09%09%09%09%09%09%09%09%09clazz = null;%0A%09%09%09%09%09%09%09%09%7D%0A%09%09%09%09%09%09%09%7D%0A%0A%09%09%09%09%09%09%7D%0A%09%09%09%09%09%09if (clazz != null && !clazz.isPrimitive()) %7B%0A%09%09%09%09%09%09%09if (!Serializable.class.isAssignableFrom(clazz)) %7B%0A%09%09%09%09%09%09%09%09fail(String%0A%09%09%09%09%09%09%09%09%09%09%09%09.format(%0A%09%09%09%09%09%09%09%09%09%09%09%09%09%09%22field %25s containing type %25s is not serializable, static, or transient but class %25s is serializable%22,%0A%09%09%09%09%09%09%09%09%09%09%09%09%09%09fld.getName(), clazz.getName(), clz.getName()));%0A%09%09%09%09%09%09%09%7D%0A%09%09%09%09%09%09%7D%0A%09%09%09%09%09%7D%0A%09%09%09%09%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A

Create SerializableContractTest.java