/*
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2002 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Apache" and "Apache Software Foundation" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    nor may "Apache" appear in their name, without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */
package net.sf.cglib;

import java.util.*;
import java.lang.reflect.*;

/**
 * @author Chris Nokleberg <a href="mailto:chris@nokleberg.com">chris@nokleberg.com</a>
 * @version $Id: JdkCompatibleProxy.java,v 1.1 2002-12-06 17:48:13 herbyderby Exp $
 */
public class JdkCompatibleProxy {
    private static final Class thisClass = JdkCompatibleProxy.class;
    private static final HandlerAdapter nullInterceptor = new HandlerAdapter(null);

    private static class HandlerAdapter implements MethodInterceptor {
        private InvocationHandler handler;
        public HandlerAdapter(InvocationHandler handler) {
            this.handler = handler;
        }

        public Object aroundAdvice(Object obj, Method method, Object[] args,
                                   MethodProxy proxy) throws Throwable {
            return handler.invoke(obj, method, args);
        }
    }

    protected InvocationHandler h;

    protected JdkCompatibleProxy(MethodInterceptor mi) {
        HandlerAdapter adapter = (HandlerAdapter)mi;
        if (adapter != null)
            h = adapter.handler;
    }

    public static InvocationHandler getInvocationHandler(Object proxy) {
        return ((HandlerAdapter)((Factory)proxy).getInterceptor()).handler;
    }

    public static Class getProxyClass(ClassLoader loader, Class[] interfaces) {
        return Enhancer.enhance(thisClass, interfaces, nullInterceptor, loader).getClass();
    }

    public static boolean isProxyClass(Class cl) {
        return cl.getSuperclass().equals(thisClass);
    }

    public static Object newProxyInstance(ClassLoader loader, Class[] interfaces, InvocationHandler h) {
        return Enhancer.enhance(thisClass, interfaces, new HandlerAdapter(h), loader);
    }        
}

@@ -2580,16 +2580,45 @@
 cglib;%0A%0A
+import java.io.Serializable;%0A
 import j
@@ -2662,16 +2662,628 @@
 *;%0A%0A/**%0A
+ * This class is meant to be used as a drop-in replacement for%0A * %3Ccode%3Ejava.lang.reflect.Proxy%3C/code%3E. There are some known subtle differences:%0A * %3Cul%3E%0A * %3Cli%3EThe exceptions returned by invoking %3Ccode%3EgetExceptionTypes%3C/code%3E%0A * on the %3Ccode%3EMethod%3C/code%3E passed to the %3Ccode%3Einvoke%3C/code%3E method%0A * %3Cb%3Eare%3C/b%3E the exact set that can be thrown without resulting in an%0A * %3Ccode%3EUndeclaredThrowableException%3C/code%3E being thrown.%0A * %3Cli%3EThere is no protected constructor which accepts an%0A * %3Ccode%3EInvocationHandler%3C/code%3E. Instead, use the more convenient%0A * %3Ccode%3EnewProxyInstance%3C/code%3E static method.%0A * %3C/ul%3E %0A
  * @auth
@@ -3407,17 +3407,17 @@
 ava,v 1.
-1
+2
  2002-12
@@ -3425,15 +3425,15 @@
 06 1
-7:48:13
+8:28:46
  her
@@ -3482,16 +3482,40 @@
 leProxy 
+implements Serializable 
 %7B%0A    pr
@@ -4738,16 +4738,26 @@
 class().
+getName().
 equals(t
@@ -4764,16 +4764,26 @@
 hisClass
+.getName()
 );%0A    %7D

Add some javadoc, make isProxyClass safer.