shadowapi/src/main/java/org/robolectric/util/ReflectionHelpers.java
public static <T> T createDeepProxy(Class<T> clazz) {
    return (T)
        Proxy.newProxyInstance(
            clazz.getClassLoader(),
            new Class[] {clazz},
            new InvocationHandler() {
              @Override
              public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                if (PRIMITIVE_RETURN_VALUES.containsKey(method.getReturnType().getName())) {
                  return PRIMITIVE_RETURN_VALUES.get(method.getReturnType().getName());
                } else if (method.getReturnType().isInterface()) {
                  return createDeepProxy(method.getReturnType());
                } else {
                  return null;
                }
              }
            });
  }
public static <T> T createDeepProxy(Class<T> clazz) {
    return (T)
        Proxy.newProxyInstance(
            clazz.getClassLoader(),
            new Class[] {clazz},
            new InvocationHandler() {
              @Override
              public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                if (PRIMITIVE_RETURN_VALUES.containsKey(method.getReturnType().getName())) {
                  return PRIMITIVE_RETURN_VALUES.get(method.getReturnType().getName());
                } else if (method.getReturnType().isInterface()) {
                  return createDeepProxy(method.getReturnType());
                } else {
                  return null;
                }
              }
            });
  }
Create a proxy for the given class which returns other deep proxies from all it's methods.

<p>The returned object will be an instance of the given class, but all methods will return
either the "default" value for primitives, or another deep proxy for non-primitive types.

<p>This should be used rarely, for cases where we need to create deep proxies in order not
to crash. The inner proxies are impossible to configure, so there is no way to create
meaningful behavior from a deep proxy. It serves mainly to prevent Null Pointer Exceptions.
@param clazz the class to provide a proxy instance of.
@return a new "Deep Proxy" instance of the given class.