2362N/A * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 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 * 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 * 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. 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 0N/A * An implementation of the <code>InvocationHandler</code> interface for 0N/A * use with Java Remote Method Invocation (Java RMI). This invocation 0N/A * handler can be used in conjunction with a dynamic proxy instance as a 0N/A * replacement for a pregenerated stub class. 0N/A * <p>Applications are not expected to use this class directly. A remote 0N/A * object exported to use a dynamic proxy with {@link UnicastRemoteObject} 0N/A * or {@link Activatable} has an instance of this class as that proxy's 0N/A * invocation handler. 0N/A * @author Ann Wollrath 0N/A * A weak hash map, mapping classes to weak hash maps that map 0N/A * method objects to method hashes. 0N/A * Creates a new <code>RemoteObjectInvocationHandler</code> constructed 0N/A * with the specified <code>RemoteRef</code>. 0N/A * @param ref the remote ref 0N/A * @throws NullPointerException if <code>ref</code> is <code>null</code> 0N/A * Processes a method invocation made on the encapsulating 0N/A * proxy instance, <code>proxy</code>, and returns the result. 0N/A * <p><code>RemoteObjectInvocationHandler</code> implements this method 0N/A * <p>If <code>method</code> is one of the following methods, it 0N/A * is processed as described below: 0N/A * <li>{@link Object#hashCode Object.hashCode}: Returns the hash 0N/A * code value for the proxy. 0N/A * <li>{@link Object#equals Object.equals}: Returns <code>true</code> 0N/A * if the argument (<code>args[0]</code>) is an instance of a dynamic 0N/A * proxy class and this invocation handler is equal to the invocation 0N/A * handler of that argument, and returns <code>false</code> otherwise. 0N/A * <li>{@link Object#toString Object.toString}: Returns a string 0N/A * representation of the proxy. 0N/A * <p>Otherwise, a remote call is made as follows: 0N/A * <li>If <code>proxy</code> is not an instance of the interface 0N/A * {@link Remote}, then an {@link IllegalArgumentException} is thrown. 0N/A * <li>Otherwise, the {@link RemoteRef#invoke invoke} method is invoked 0N/A * on this invocation handler's <code>RemoteRef</code>, passing 0N/A * <code>proxy</code>, <code>method</code>, <code>args</code>, and the 0N/A * method hash (defined in section 8.3 of the "Java Remote Method 0N/A * Invocation (RMI) Specification") for <code>method</code>, and the 0N/A * result is returned. 0N/A * <li>If an exception is thrown by <code>RemoteRef.invoke</code> and 0N/A * that exception is a checked exception that is not assignable to any 0N/A * exception in the <code>throws</code> clause of the method 0N/A * implemented by the <code>proxy</code>'s class, then that exception 0N/A * is wrapped in an {@link UnexpectedException} and the wrapped 0N/A * exception is thrown. Otherwise, the exception thrown by 0N/A * <code>invoke</code> is thrown by this method. 0N/A * <p>The semantics of this method are unspecified if the 0N/A * arguments could not have been produced by an instance of some 0N/A * valid dynamic proxy class containing this invocation handler. 0N/A * @param proxy the proxy instance that the method was invoked on 0N/A * @param method the <code>Method</code> instance corresponding to the 0N/A * interface method invoked on the proxy instance 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, or 0N/A * <code>null</code> if the method takes no arguments 0N/A * @return the value to return from the method invocation on the proxy 0N/A * @throws Throwable the exception to throw from the method invocation 0N/A * on the proxy instance 0N/A * Handles java.lang.Object methods. 0N/A * Handles remote methods. 0N/A "proxy not Remote instance");
0N/A * Returns a string representation for a proxy that uses this invocation 0N/A return "Proxy[" +
this +
"]";
0N/A return "Proxy[" +
iface +
"," +
this +
"]";
0N/A * @throws InvalidObjectException unconditionally 0N/A * Returns the method hash for the specified method. Subsequent calls 0N/A * to "getMethodHash" passing the same method argument should be faster 0N/A * since this method caches internally the result of the method to 0N/A * method hash mapping. The method hash is calculated using the 0N/A * "computeMethodHash" method. 0N/A * @param method the remote method 0N/A * @return the method hash for the specified method 0N/A * A weak hash map, mapping classes to weak hash maps that map 0N/A * method objects to method hashes.