0N/A/*
2362N/A * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage java.lang.reflect;
0N/A
0N/A/**
0N/A * {@code InvocationHandler} is the interface implemented by
0N/A * the <i>invocation handler</i> of a proxy instance.
0N/A *
0N/A * <p>Each proxy instance has an associated invocation handler.
0N/A * When a method is invoked on a proxy instance, the method
0N/A * invocation is encoded and dispatched to the {@code invoke}
0N/A * method of its invocation handler.
0N/A *
0N/A * @author Peter Jones
0N/A * @see Proxy
0N/A * @since 1.3
0N/A */
0N/Apublic interface InvocationHandler {
0N/A
0N/A /**
0N/A * Processes a method invocation on a proxy instance and returns
0N/A * the result. This method will be invoked on an invocation handler
0N/A * when a method is invoked on a proxy instance that it is
0N/A * associated with.
0N/A *
0N/A * @param proxy the proxy instance that the method was invoked on
0N/A *
0N/A * @param method the {@code Method} instance corresponding to
0N/A * the interface method invoked on the proxy instance. The declaring
0N/A * class of the {@code Method} object will be the interface that
0N/A * the method was declared in, which may be a superinterface of the
0N/A * proxy interface that the proxy class inherits the method through.
0N/A *
0N/A * @param args an array of objects containing the values of the
0N/A * arguments passed in the method invocation on the proxy instance,
0N/A * or {@code null} if interface method takes no arguments.
0N/A * Arguments of primitive types are wrapped in instances of the
0N/A * appropriate primitive wrapper class, such as
0N/A * {@code java.lang.Integer} or {@code java.lang.Boolean}.
0N/A *
0N/A * @return the value to return from the method invocation on the
0N/A * proxy instance. If the declared return type of the interface
0N/A * method is a primitive type, then the value returned by
0N/A * this method must be an instance of the corresponding primitive
0N/A * wrapper class; otherwise, it must be a type assignable to the
0N/A * declared return type. If the value returned by this method is
0N/A * {@code null} and the interface method's return type is
0N/A * primitive, then a {@code NullPointerException} will be
0N/A * thrown by the method invocation on the proxy instance. If the
0N/A * value returned by this method is otherwise not compatible with
0N/A * the interface method's declared return type as described above,
0N/A * a {@code ClassCastException} will be thrown by the method
0N/A * invocation on the proxy instance.
0N/A *
0N/A * @throws Throwable the exception to throw from the method
0N/A * invocation on the proxy instance. The exception's type must be
0N/A * assignable either to any of the exception types declared in the
0N/A * {@code throws} clause of the interface method or to the
0N/A * unchecked exception types {@code java.lang.RuntimeException}
0N/A * or {@code java.lang.Error}. If a checked exception is
0N/A * thrown by this method that is not assignable to any of the
0N/A * exception types declared in the {@code throws} clause of
0N/A * the interface method, then an
0N/A * {@link UndeclaredThrowableException} containing the
0N/A * exception that was thrown by this method will be thrown by the
0N/A * method invocation on the proxy instance.
0N/A *
0N/A * @see UndeclaredThrowableException
0N/A */
0N/A public Object invoke(Object proxy, Method method, Object[] args)
0N/A throws Throwable;
0N/A}