if (type.getDeclaringClass() != null && !Modifier.isStatic(type.getModifiers())) {
throw new IllegalArgumentException("cannot mock non-static inner class " + type.getName());
}
return (Mock) new CglibProxyFactory().createProxy(new Class[]{type, Mock.class, ExpectationRegistry.class},
new Invoker() {
final ClassMockObject mock = new ClassMockObject(type, name);
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
try {
Class targetClass = method.getDeclaringClass();