2362N/A * Copyright (c) 1996, 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 * Object table shared by all implementors of the Transport interface. 0N/A * This table maps object ids to remote object targets in this address 0N/A * @author Ann Wollrath 0N/A * @author Peter Jones 0N/A /** maximum interval between complete garbage collections of local heap */ 0N/A * lock guarding objTable and implTable. 0N/A * Holders MAY acquire a Target instance's lock or keepAliveLock. 0N/A /** tables mapping to Target, keyed from ObjectEndpoint and impl object */ 0N/A * lock guarding keepAliveCount, reaper, and gcLatencyRequest. 0N/A * Holders may NOT acquire a Target instance's lock or tableLock. 0N/A /** count of non-permanent objects in table or still processing calls */ 0N/A /** thread to collect unreferenced objects from table */ 0N/A /** queue notified when weak refs in the table are cleared */ 0N/A /** handle for GC latency request (for future cancellation) */ 0N/A * Disallow anyone from creating one of these. 0N/A * Returns the target associated with the object id. 0N/A * Returns the target associated with the remote object 0N/A * Returns the stub for the remote object <b>obj</b> passed 0N/A * as a parameter. This operation is only valid <i>after</i> 0N/A * the object has been exported. 0N/A * @return the stub for the remote object, <b>obj</b>. 0N/A * @exception NoSuchObjectException if the stub for the 0N/A * remote object could not be found. 0N/A * Remove the remote object, obj, from the RMI runtime. If 0N/A * successful, the object can no longer accept incoming RMI calls. 0N/A * If the force parameter is true, the object is forcibly unexported 0N/A * even if there are pending calls to the remote object or the 0N/A * remote object still has calls in progress. If the force 0N/A * parameter is false, the object is only unexported if there are 0N/A * no pending or in progress calls to the object. 0N/A * @param obj the remote object to be unexported 0N/A * @param force if true, unexports the object even if there are 0N/A * pending or in-progress calls; if false, only unexports the object 0N/A * if there are no pending or in-progress calls 0N/A * @return true if operation is successful, false otherwise 0N/A * @exception NoSuchObjectException if the remote object is not 0N/A * currently exported 0N/A * Add target to object table. If it is not a permanent entry, then 0N/A * make sure that reaper thread is running to remove collected entries 0N/A * and keep VM alive. 4005N/A * Do nothing if impl has already been collected (see 6597112). Check while 4005N/A * holding tableLock to ensure that Reaper cannot process weakImpl in between 4005N/A "internal error: ObjID already in use");
0N/A * Remove target from object table. 0N/A * NOTE: This method must only be invoked while synchronized on 0N/A * the "tableLock" object, because it does not do so itself. 0N/A // assert Thread.holdsLock(tableLock); 0N/A * Process client VM signalling reference for given ObjID: forward to 0N/A * correspoding Target entry. If ObjID is not found in table, 0N/A * no action is taken. 0N/A * Process client VM dropping reference for given ObjID: forward to 0N/A * correspoding Target entry. If ObjID is not found in table, 0N/A * no action is taken. 0N/A * Increments the "keep-alive count". 0N/A * The "keep-alive count" is the number of non-permanent remote objects 0N/A * that are either in the object table or still have calls in progress. 0N/A * Therefore, this method should be invoked exactly once for every 0N/A * non-permanent remote object exported (a remote object must be 0N/A * exported before it can have any calls in progress). 0N/A * The VM is "kept alive" while the keep-alive count is greater than 0N/A * zero; this is accomplished by keeping a non-daemon thread running. 0N/A * Because non-permanent objects are those that can be garbage 0N/A * collected while exported, and thus those for which the "reaper" 0N/A * thread operates, the reaper thread also serves as the non-daemon 0N/A * VM keep-alive thread; a new reaper thread is created if necessary. 0N/A * While there are non-"permanent" objects in the object table, 0N/A * request a maximum latency for inspecting the entire heap 0N/A * from the local garbage collector, to place an upper bound 0N/A * on the time to discover remote objects that have become 0N/A * unreachable (and thus can be removed from the table). 0N/A * Decrements the "keep-alive count". 0N/A * The "keep-alive count" is the number of non-permanent remote objects 0N/A * that are either in the object table or still have calls in progress. 0N/A * Therefore, this method should be invoked exactly once for every 0N/A * previously-exported non-permanent remote object that both has been 0N/A * removed from the object table and has no calls still in progress. 0N/A * If the keep-alive count is decremented to zero, then the current 0N/A * reaper thread is terminated to cease keeping the VM alive (and 0N/A * because there are no more non-permanent remote objects to reap). 0N/A * If there are no longer any non-permanent objects in the 0N/A * object table, we are no longer concerned with the latency 0N/A * of local garbage collection here. 0N/A * The Reaper thread waits for notifications that weak references in the 0N/A * object table have been cleared. When it receives a notification, it 0N/A * removes the corresponding entry from the table. 0N/A * Since the Reaper is created as a non-daemon thread, it also serves 0N/A * to keep the VM from exiting while there are objects in the table 0N/A * (other than permanent entries that should neither be reaped nor 0N/A * keep the VM alive). 0N/A // wait for next cleared weak reference 0N/A "object with known references collected");
0N/A throw new Error(
"permanent object collected");
0N/A // pass away if interrupted