1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/rt/emul/mini/src/main/java/java/lang/reflect/InvocationHandler.java Tue Feb 26 16:54:16 2013 +0100
1.3 @@ -0,0 +1,95 @@
1.4 +/*
1.5 + * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1.7 + *
1.8 + * This code is free software; you can redistribute it and/or modify it
1.9 + * under the terms of the GNU General Public License version 2 only, as
1.10 + * published by the Free Software Foundation. Oracle designates this
1.11 + * particular file as subject to the "Classpath" exception as provided
1.12 + * by Oracle in the LICENSE file that accompanied this code.
1.13 + *
1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1.17 + * version 2 for more details (a copy is included in the LICENSE file that
1.18 + * accompanied this code).
1.19 + *
1.20 + * You should have received a copy of the GNU General Public License version
1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1.23 + *
1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1.25 + * or visit www.oracle.com if you need additional information or have any
1.26 + * questions.
1.27 + */
1.28 +
1.29 +package java.lang.reflect;
1.30 +
1.31 +/**
1.32 + * {@code InvocationHandler} is the interface implemented by
1.33 + * the <i>invocation handler</i> of a proxy instance.
1.34 + *
1.35 + * <p>Each proxy instance has an associated invocation handler.
1.36 + * When a method is invoked on a proxy instance, the method
1.37 + * invocation is encoded and dispatched to the {@code invoke}
1.38 + * method of its invocation handler.
1.39 + *
1.40 + * @author Peter Jones
1.41 + * @see Proxy
1.42 + * @since 1.3
1.43 + */
1.44 +public interface InvocationHandler {
1.45 +
1.46 + /**
1.47 + * Processes a method invocation on a proxy instance and returns
1.48 + * the result. This method will be invoked on an invocation handler
1.49 + * when a method is invoked on a proxy instance that it is
1.50 + * associated with.
1.51 + *
1.52 + * @param proxy the proxy instance that the method was invoked on
1.53 + *
1.54 + * @param method the {@code Method} instance corresponding to
1.55 + * the interface method invoked on the proxy instance. The declaring
1.56 + * class of the {@code Method} object will be the interface that
1.57 + * the method was declared in, which may be a superinterface of the
1.58 + * proxy interface that the proxy class inherits the method through.
1.59 + *
1.60 + * @param args an array of objects containing the values of the
1.61 + * arguments passed in the method invocation on the proxy instance,
1.62 + * or {@code null} if interface method takes no arguments.
1.63 + * Arguments of primitive types are wrapped in instances of the
1.64 + * appropriate primitive wrapper class, such as
1.65 + * {@code java.lang.Integer} or {@code java.lang.Boolean}.
1.66 + *
1.67 + * @return the value to return from the method invocation on the
1.68 + * proxy instance. If the declared return type of the interface
1.69 + * method is a primitive type, then the value returned by
1.70 + * this method must be an instance of the corresponding primitive
1.71 + * wrapper class; otherwise, it must be a type assignable to the
1.72 + * declared return type. If the value returned by this method is
1.73 + * {@code null} and the interface method's return type is
1.74 + * primitive, then a {@code NullPointerException} will be
1.75 + * thrown by the method invocation on the proxy instance. If the
1.76 + * value returned by this method is otherwise not compatible with
1.77 + * the interface method's declared return type as described above,
1.78 + * a {@code ClassCastException} will be thrown by the method
1.79 + * invocation on the proxy instance.
1.80 + *
1.81 + * @throws Throwable the exception to throw from the method
1.82 + * invocation on the proxy instance. The exception's type must be
1.83 + * assignable either to any of the exception types declared in the
1.84 + * {@code throws} clause of the interface method or to the
1.85 + * unchecked exception types {@code java.lang.RuntimeException}
1.86 + * or {@code java.lang.Error}. If a checked exception is
1.87 + * thrown by this method that is not assignable to any of the
1.88 + * exception types declared in the {@code throws} clause of
1.89 + * the interface method, then an
1.90 + * {@link UndeclaredThrowableException} containing the
1.91 + * exception that was thrown by this method will be thrown by the
1.92 + * method invocation on the proxy instance.
1.93 + *
1.94 + * @see UndeclaredThrowableException
1.95 + */
1.96 + public Object invoke(Object proxy, Method method, Object[] args)
1.97 + throws Throwable;
1.98 +}