code: @Override
    @SuppressWarnings("unchecked") // safe since the proxy implements type
    public T getFake(Class<?> type) {
      return (T) Proxy.newProxyInstance(FakeMessagesProvider.class.getClassLoader(), new Class<?>[] {type},
          new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Exception {
              if (method.getName().equals("ensureInjected")) {
                return true;
              } else if (method.getName().equals("hashCode")) {
                return proxy.getClass().hashCode();
              } else if (method.getName().equals("equals")) {
                return proxy.getClass().equals(args[0].getClass());
              } else if (method.getReturnType() == String.class) {
                return buildMessage(method, args);
              } else if (method.getReturnType() == SafeHtml.class) {
                return SafeHtmlUtils.fromTrustedString(buildMessage(method, args));
              } else {
                throw new IllegalArgumentException(method.getName()
                    + " must return either String or SafeHtml");
              }
            }
          });
    }
docs: Returns a new instance of the given type that implements methods as
  described in the class description.
  
  @param type interface to be implemented by the returned type.