/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A target contains information pertaining to a remote object that
* resides in this address space. Targets are located via the
* ObjectTable.
*/
public final class Target {
/** object id for target */
/** flag indicating whether target is subject to collection */
private final boolean permanent;
/** weak reference to remote object implementation */
/** dispatcher for remote object */
/** stub for remote object */
/** set of clients that hold references to this target */
/** table that maps client endpoints to sequence numbers */
new Hashtable<>(5);
/** access control context in which target was created */
/** context class loader in which target was created */
/** true if this target has been removed from the object table */
private boolean removed = false;
/**
* the transport through which this target was exported and
* through which remote calls will be allowed
*/
/** number to identify next callback thread created here */
/**
* Construct a Target for a remote object "impl" with
* a specific object id.
*
* If "permanent" is true, then the impl is pinned permanently
* GC). If "on" is false, than the impl is subject to
* collection. Permanent objects do not keep a server from
* exiting.
*/
boolean permanent)
{
/*
* Fix for 4149366: so that downloaded parameter types unmarshalled
* for this impl will be compatible with types known only to the
* impl class's class loader (when it's not identical to the
* exporting thread's context class loader), mark the impl's class
* loader as the loader to use as the context class loader in the
* server's dispatch thread while a call to this impl is being
* processed (unless this exporting thread's context class loader is
* a child of the impl's class loader, such as when a registry is
* exported by an application, in which case this thread's context
* class loader is preferred).
*/
this.ccl = threadContextLoader;
} else {
this.ccl = serverLoader;
}
if (permanent) {
pinImpl();
}
}
/**
* Return true if the first class loader is a child of (or identical
* to) the second class loader. Either loader may be "null", which is
* considered to be the parent of any non-null class loader.
*
* (utility method added for the 1.2beta4 fix for 4149366)
*/
{
return true;
return false;
} else {
{
return true;
}
}
return false;
}
}
/** Get the stub (proxy) object for this target
*/
return stub;
}
/**
* Returns the object endpoint for the target.
*/
}
/**
* Get the weak reference for the Impl of this target.
*/
return weakImpl;
}
/**
* Returns the dispatcher for this remote object target.
*/
return disp;
}
return acc;
}
return ccl;
}
/**
* Get the impl for this target.
* Note: this may return null if the impl has been garbage collected.
* (currently, there is no need to make this method public)
*/
}
/**
* Returns true if the target is permanent.
*/
boolean isPermanent() {
return permanent;
}
/**
* Pin impl in target. Pin the WeakRef object so it holds a strong
* reference to the object to it will not be garbage collected locally.
* This way there is a single object responsible for the weak ref
* mechanism.
*/
synchronized void pinImpl() {
}
/**
* Unpin impl in target. Weaken the reference to impl so that it
* can be garbage collected locally. But only if there the refSet
*/
synchronized void unpinImpl() {
/* only unpin if:
* a) impl is not permanent, and
* b) impl is not already unpinned, and
* c) there are no external references (outside this
* address space) for the impl
*/
}
}
/**
* Enable the transport through which remote calls to this target
* are allowed to be set if it has not already been set.
*/
if (this.exportedTransport == null) {
this.exportedTransport = exportedTransport;
}
}
/**
* Add an endpoint to the remembered set. Also adds a notifier
* to call back if the address space associated with the endpoint
* dies.
*/
// check sequence number for vmid
} else {
// late dirty call; ignore.
return;
}
/*
* A Target must be pinned while its refSet is not empty. It may
* have become unpinned if external LiveRefs only existed in
* serialized form for some period of time, or if a client failed
* to renew its lease due to a transient network failure. So,
* make sure that it is pinned here; this fixes bugid 4069644.
*/
pinImpl();
return;
}
}
}
/**
* Remove endpoint from remembered set. If set becomes empty,
* remove server from Transport's object table.
*/
{
// check sequence number for vmid
// late clean call; ignore
return;
} else if (strong) {
// strong clean call; retain sequenceNum
// get rid of sequence number
}
}
}
/**
* Remove endpoint from the reference set.
*/
// remove notification request
// reference set is empty, so server can be garbage collected.
// remove object from table.
"reference set is empty: target = " + this);
}
/*
* If the remote object implements the Unreferenced interface,
* invoke its unreferenced callback in a separate thread.
*/
if (obj instanceof Unreferenced) {
final Thread t =
new NewThreadAction(new Runnable() {
public void run() {
}
}, "Unreferenced-" + nextThreadNum++, false, true));
// REMIND: access to nextThreadNum not synchronized; you care?
/*
* We must manually set the context class loader appropriately
* for threads that may invoke user code (see bugid 4171278).
*/
return null;
}
});
t.start();
}
unpinImpl();
}
}
/**
* Mark this target as not accepting new calls if any of the
* following conditions exist: a) the force parameter is true,
* b) the target's call count is zero, or c) the object is already
* not accepting calls. Returns true if target is marked as not
* accepting new calls; returns false otherwise.
*/
/*
* Fix for 4331349: unpin object so that it may be gc'd.
* Also, unregister all vmids referencing this target
* so target can be gc'd.
*/
unpinImpl();
while (enum_.hasMoreElements()) {
}
return true;
} else {
return false;
}
}
/**
* Mark this target as having been removed from the object table.
*/
synchronized void markRemoved() {
if (!(!removed)) { throw new AssertionError(); }
removed = true;
}
if (exportedTransport != null) {
}
}
/**
* Increment call count.
*/
callCount ++;
} else {
throw new NoSuchObjectException("object not accepting new calls");
}
}
/**
* Decrement call count.
*/
synchronized void decrementCallCount() {
if (--callCount < 0) {
throw new Error("internal error: call count less than zero");
}
/*
* The "keep-alive count" is the number of non-permanent remote
* objects that are either in the object table or still have calls
* in progress. Therefore, this state change may affect the
* keep-alive count: if this target is for a non-permanent remote
* object that has been removed from the object table and now has a
* call count of zero, it needs to be decremented.
*/
}
}
/**
* Returns true if remembered set is empty; otherwise returns
* false
*/
boolean isEmpty() {
}
/**
* This method is called if the address space associated with the
* vmid dies. In that case, the vmid should be removed
* from the reference set.
*/
vmid + " from reference set");
}
}
}
class SequenceEntry {
long sequenceNum;
boolean keep;
this.sequenceNum = sequenceNum;
keep = false;
}
this.sequenceNum = sequenceNum;
keep = true;
}
this.sequenceNum = sequenceNum;
}
}