}
@SuppressWarnings("unchecked")
public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException {
if (isProxyClass(target.getClass())) {
Factory factory = (Factory)target;
Callback[] callbacks = factory.getCallbacks();
if (callbacks.length != 1 || !(callbacks[0] instanceof CglibMethodInterceptor)) {
throw new IllegalArgumentException("The object is not a known proxy.");
}
CglibMethodInterceptor interceptor = (CglibMethodInterceptor)callbacks[0];
return (R)interceptor.invocationHandler.getCallableReference();