java.rmi.dgc.VMID Java Examples

The following examples show how to use java.rmi.dgc.VMID. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Target.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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.
 */
synchronized boolean unexport(boolean force) {

    if ((force == true) || (callCount == 0) || (disp == null)) {
        disp = null;
        /*
         * 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();
        DGCImpl dgc = DGCImpl.getDGCImpl();
        Enumeration<VMID> enum_ = refSet.elements();
        while (enum_.hasMoreElements()) {
            VMID vmid = enum_.nextElement();
            dgc.unregisterTarget(vmid, this);
        }
        return true;
    } else {
        return false;
    }
}
 
Example #2
Source File: Target.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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.
 */
synchronized boolean unexport(boolean force) {

    if ((force == true) || (callCount == 0) || (disp == null)) {
        disp = null;
        /*
         * 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();
        DGCImpl dgc = DGCImpl.getDGCImpl();
        Enumeration<VMID> enum_ = refSet.elements();
        while (enum_.hasMoreElements()) {
            VMID vmid = enum_.nextElement();
            dgc.unregisterTarget(vmid, this);
        }
        return true;
    } else {
        return false;
    }
}
 
Example #3
Source File: Target.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Remove endpoint from remembered set.  If set becomes empty,
 * remove server from Transport's object table.
 */
synchronized void unreferenced(long sequenceNum, VMID vmid, boolean strong)
{
    // check sequence number for vmid
    SequenceEntry entry = sequenceTable.get(vmid);
    if (entry == null || entry.sequenceNum > sequenceNum) {
        // late clean call; ignore
        return;
    } else if (strong) {
        // strong clean call; retain sequenceNum
        entry.retain(sequenceNum);
    } else if (entry.keep == false) {
        // get rid of sequence number
        sequenceTable.remove(vmid);
    }

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "remove from dirty set: " + vmid);
    }

    refSetRemove(vmid);
}
 
Example #4
Source File: Target.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Remove endpoint from remembered set.  If set becomes empty,
 * remove server from Transport's object table.
 */
synchronized void unreferenced(long sequenceNum, VMID vmid, boolean strong)
{
    // check sequence number for vmid
    SequenceEntry entry = sequenceTable.get(vmid);
    if (entry == null || entry.sequenceNum > sequenceNum) {
        // late clean call; ignore
        return;
    } else if (strong) {
        // strong clean call; retain sequenceNum
        entry.retain(sequenceNum);
    } else if (entry.keep == false) {
        // get rid of sequence number
        sequenceTable.remove(vmid);
    }

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "remove from dirty set: " + vmid);
    }

    refSetRemove(vmid);
}
 
Example #5
Source File: Target.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Remove endpoint from remembered set.  If set becomes empty,
 * remove server from Transport's object table.
 */
synchronized void unreferenced(long sequenceNum, VMID vmid, boolean strong)
{
    // check sequence number for vmid
    SequenceEntry entry = sequenceTable.get(vmid);
    if (entry == null || entry.sequenceNum > sequenceNum) {
        // late clean call; ignore
        return;
    } else if (strong) {
        // strong clean call; retain sequenceNum
        entry.retain(sequenceNum);
    } else if (entry.keep == false) {
        // get rid of sequence number
        sequenceTable.remove(vmid);
    }

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "remove from dirty set: " + vmid);
    }

    refSetRemove(vmid);
}
 
Example #6
Source File: Target.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Remove endpoint from remembered set.  If set becomes empty,
 * remove server from Transport's object table.
 */
synchronized void unreferenced(long sequenceNum, VMID vmid, boolean strong)
{
    // check sequence number for vmid
    SequenceEntry entry = sequenceTable.get(vmid);
    if (entry == null || entry.sequenceNum > sequenceNum) {
        // late clean call; ignore
        return;
    } else if (strong) {
        // strong clean call; retain sequenceNum
        entry.retain(sequenceNum);
    } else if (entry.keep == false) {
        // get rid of sequence number
        sequenceTable.remove(vmid);
    }

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "remove from dirty set: " + vmid);
    }

    refSetRemove(vmid);
}
 
Example #7
Source File: Target.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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.
 */
synchronized boolean unexport(boolean force) {

    if ((force == true) || (callCount == 0) || (disp == null)) {
        disp = null;
        /*
         * 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();
        DGCImpl dgc = DGCImpl.getDGCImpl();
        Enumeration<VMID> enum_ = refSet.elements();
        while (enum_.hasMoreElements()) {
            VMID vmid = enum_.nextElement();
            dgc.unregisterTarget(vmid, this);
        }
        return true;
    } else {
        return false;
    }
}
 
Example #8
Source File: Target.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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.
 */
synchronized boolean unexport(boolean force) {

    if ((force == true) || (callCount == 0) || (disp == null)) {
        disp = null;
        /*
         * 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();
        DGCImpl dgc = DGCImpl.getDGCImpl();
        Enumeration<VMID> enum_ = refSet.elements();
        while (enum_.hasMoreElements()) {
            VMID vmid = enum_.nextElement();
            dgc.unregisterTarget(vmid, this);
        }
        return true;
    } else {
        return false;
    }
}
 
Example #9
Source File: Target.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Remove endpoint from remembered set.  If set becomes empty,
 * remove server from Transport's object table.
 */
synchronized void unreferenced(long sequenceNum, VMID vmid, boolean strong)
{
    // check sequence number for vmid
    SequenceEntry entry = sequenceTable.get(vmid);
    if (entry == null || entry.sequenceNum > sequenceNum) {
        // late clean call; ignore
        return;
    } else if (strong) {
        // strong clean call; retain sequenceNum
        entry.retain(sequenceNum);
    } else if (entry.keep == false) {
        // get rid of sequence number
        sequenceTable.remove(vmid);
    }

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "remove from dirty set: " + vmid);
    }

    refSetRemove(vmid);
}
 
Example #10
Source File: Target.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Remove endpoint from remembered set.  If set becomes empty,
 * remove server from Transport's object table.
 */
synchronized void unreferenced(long sequenceNum, VMID vmid, boolean strong)
{
    // check sequence number for vmid
    SequenceEntry entry = sequenceTable.get(vmid);
    if (entry == null || entry.sequenceNum > sequenceNum) {
        // late clean call; ignore
        return;
    } else if (strong) {
        // strong clean call; retain sequenceNum
        entry.retain(sequenceNum);
    } else if (entry.keep == false) {
        // get rid of sequence number
        sequenceTable.remove(vmid);
    }

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "remove from dirty set: " + vmid);
    }

    refSetRemove(vmid);
}
 
Example #11
Source File: Target.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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.
 */
synchronized boolean unexport(boolean force) {

    if ((force == true) || (callCount == 0) || (disp == null)) {
        disp = null;
        /*
         * 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();
        DGCImpl dgc = DGCImpl.getDGCImpl();
        Enumeration<VMID> enum_ = refSet.elements();
        while (enum_.hasMoreElements()) {
            VMID vmid = enum_.nextElement();
            dgc.unregisterTarget(vmid, this);
        }
        return true;
    } else {
        return false;
    }
}
 
Example #12
Source File: Target.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Remove endpoint from remembered set.  If set becomes empty,
 * remove server from Transport's object table.
 */
synchronized void unreferenced(long sequenceNum, VMID vmid, boolean strong)
{
    // check sequence number for vmid
    SequenceEntry entry = sequenceTable.get(vmid);
    if (entry == null || entry.sequenceNum > sequenceNum) {
        // late clean call; ignore
        return;
    } else if (strong) {
        // strong clean call; retain sequenceNum
        entry.retain(sequenceNum);
    } else if (entry.keep == false) {
        // get rid of sequence number
        sequenceTable.remove(vmid);
    }

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "remove from dirty set: " + vmid);
    }

    refSetRemove(vmid);
}
 
Example #13
Source File: CheckVMID.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {

        System.err.println("\nRegression test for bug 4171370\n");

        TestLibrary.suggestSecurityManager(null);

        try {
            System.err.println("Create a VMID");
            VMID vmid = new VMID();
            System.err.println("vmid = " + vmid);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("TEST FAILED: " + e.toString());
        }
    }
 
Example #14
Source File: DGCImpl_Stub.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ObjectInputFilter to filter DGCClient return value (a Lease).
 * The list of acceptable classes is very short and explicit.
 * The depth and array sizes are limited.
 *
 * @param filterInfo access to class, arrayLength, etc.
 * @return  {@link ObjectInputFilter.Status#ALLOWED} if allowed,
 *          {@link ObjectInputFilter.Status#REJECTED} if rejected,
 *          otherwise {@link ObjectInputFilter.Status#UNDECIDED}
 */
private static ObjectInputFilter.Status leaseFilter(ObjectInputFilter.FilterInfo filterInfo) {

    if (filterInfo.depth() > DGCCLIENT_MAX_DEPTH) {
        return ObjectInputFilter.Status.REJECTED;
    }
    Class<?> clazz = filterInfo.serialClass();
    if (clazz != null) {
        while (clazz.isArray()) {
            if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > DGCCLIENT_MAX_ARRAY_SIZE) {
                return ObjectInputFilter.Status.REJECTED;
            }
            // Arrays are allowed depending on the component type
            clazz = clazz.getComponentType();
        }
        if (clazz.isPrimitive()) {
            // Arrays of primitives are allowed
            return ObjectInputFilter.Status.ALLOWED;
        }
        return (clazz == UID.class ||
                clazz == VMID.class ||
                clazz == Lease.class)
                ? ObjectInputFilter.Status.ALLOWED
                : ObjectInputFilter.Status.REJECTED;
    }
    // Not a class, not size limited
    return ObjectInputFilter.Status.UNDECIDED;
}
 
Example #15
Source File: DGCImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Register interest in receiving a callback when this VMID
 * becomes inaccessible.
 */
void registerTarget(VMID vmid, Target target) {
    synchronized (leaseTable) {
        LeaseInfo info = leaseTable.get(vmid);
        if (info == null) {
            target.vmidDead(vmid);
        } else {
            info.notifySet.add(target);
        }
    }
}
 
Example #16
Source File: DGCImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ObjectInputFilter to filter DGC input objects.
 * The list of acceptable classes is very short and explicit.
 * The depth and array sizes are limited.
 *
 * @param filterInfo access to class, arrayLength, etc.
 * @return  {@link ObjectInputFilter.Status#ALLOWED} if allowed,
 *          {@link ObjectInputFilter.Status#REJECTED} if rejected,
 *          otherwise {@link ObjectInputFilter.Status#UNDECIDED}
 */
private static ObjectInputFilter.Status checkInput(ObjectInputFilter.FilterInfo filterInfo) {
    if (dgcFilter != null) {
        ObjectInputFilter.Status status = dgcFilter.checkInput(filterInfo);
        if (status != ObjectInputFilter.Status.UNDECIDED) {
            // The DGC filter can override the built-in white-list
            return status;
        }
    }

    if (filterInfo.depth() > DGC_MAX_DEPTH) {
        return ObjectInputFilter.Status.REJECTED;
    }
    Class<?> clazz = filterInfo.serialClass();
    if (clazz != null) {
        while (clazz.isArray()) {
            if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > DGC_MAX_ARRAY_SIZE) {
                return ObjectInputFilter.Status.REJECTED;
            }
            // Arrays are allowed depending on the component type
            clazz = clazz.getComponentType();
        }
        if (clazz.isPrimitive()) {
            // Arrays of primitives are allowed
            return ObjectInputFilter.Status.ALLOWED;
        }
        return (clazz == ObjID.class ||
                clazz == UID.class ||
                clazz == VMID.class ||
                clazz == Lease.class)
                ? ObjectInputFilter.Status.ALLOWED
                : ObjectInputFilter.Status.REJECTED;
    }
    // Not a class, not size limited
    return ObjectInputFilter.Status.UNDECIDED;
}
 
Example #17
Source File: Target.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add an endpoint to the remembered set.  Also adds a notifier
 * to call back if the address space associated with the endpoint
 * dies.
 */
synchronized void referenced(long sequenceNum, VMID vmid) {
    // check sequence number for vmid
    SequenceEntry entry = sequenceTable.get(vmid);
    if (entry == null) {
        sequenceTable.put(vmid, new SequenceEntry(sequenceNum));
    } else if (entry.sequenceNum < sequenceNum) {
        entry.update(sequenceNum);
    } else  {
        // late dirty call; ignore.
        return;
    }

    if (!refSet.contains(vmid)) {
        /*
         * 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();
        if (getImpl() == null)      // too late if impl was collected
            return;

        if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
            DGCImpl.dgcLog.log(Log.VERBOSE, "add to dirty set: " + vmid);
        }

        refSet.addElement(vmid);

        DGCImpl.getDGCImpl().registerTarget(vmid, this);
    }
}
 
Example #18
Source File: ObjectTable.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Process client VM dropping reference for given ObjID: forward to
 * corresponding Target entry.  If ObjID is not found in table,
 * no action is taken.
 */
static void unreferenced(ObjID id, long sequenceNum, VMID vmid,
                         boolean strong)
{
    synchronized (tableLock) {
        ObjectEndpoint oe =
            new ObjectEndpoint(id, Transport.currentTransport());
        Target target = objTable.get(oe);
        if (target != null)
            target.unreferenced(sequenceNum, vmid, strong);
    }
}
 
Example #19
Source File: Target.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add an endpoint to the remembered set.  Also adds a notifier
 * to call back if the address space associated with the endpoint
 * dies.
 */
synchronized void referenced(long sequenceNum, VMID vmid) {
    // check sequence number for vmid
    SequenceEntry entry = sequenceTable.get(vmid);
    if (entry == null) {
        sequenceTable.put(vmid, new SequenceEntry(sequenceNum));
    } else if (entry.sequenceNum < sequenceNum) {
        entry.update(sequenceNum);
    } else  {
        // late dirty call; ignore.
        return;
    }

    if (!refSet.contains(vmid)) {
        /*
         * 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();
        if (getImpl() == null)      // too late if impl was collected
            return;

        if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
            DGCImpl.dgcLog.log(Log.VERBOSE, "add to dirty set: " + vmid);
        }

        refSet.addElement(vmid);

        DGCImpl.getDGCImpl().registerTarget(vmid, this);
    }
}
 
Example #20
Source File: DGCImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ObjectInputFilter to filter DGC input objects.
 * The list of acceptable classes is very short and explicit.
 * The depth and array sizes are limited.
 *
 * @param filterInfo access to class, arrayLength, etc.
 * @return  {@link ObjectInputFilter.Status#ALLOWED} if allowed,
 *          {@link ObjectInputFilter.Status#REJECTED} if rejected,
 *          otherwise {@link ObjectInputFilter.Status#UNDECIDED}
 */
private static ObjectInputFilter.Status checkInput(ObjectInputFilter.FilterInfo filterInfo) {
    if (dgcFilter != null) {
        ObjectInputFilter.Status status = dgcFilter.checkInput(filterInfo);
        if (status != ObjectInputFilter.Status.UNDECIDED) {
            // The DGC filter can override the built-in white-list
            return status;
        }
    }

    if (filterInfo.depth() > DGC_MAX_DEPTH) {
        return ObjectInputFilter.Status.REJECTED;
    }
    Class<?> clazz = filterInfo.serialClass();
    if (clazz != null) {
        while (clazz.isArray()) {
            if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > DGC_MAX_ARRAY_SIZE) {
                return ObjectInputFilter.Status.REJECTED;
            }
            // Arrays are allowed depending on the component type
            clazz = clazz.getComponentType();
        }
        if (clazz.isPrimitive()) {
            // Arrays of primitives are allowed
            return ObjectInputFilter.Status.ALLOWED;
        }
        return (clazz == ObjID.class ||
                clazz == UID.class ||
                clazz == VMID.class ||
                clazz == Lease.class)
                ? ObjectInputFilter.Status.ALLOWED
                : ObjectInputFilter.Status.REJECTED;
    }
    // Not a class, not size limited
    return ObjectInputFilter.Status.UNDECIDED;
}
 
Example #21
Source File: DGCImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Remove notification request.
 */
void unregisterTarget(VMID vmid, Target target) {
    synchronized (leaseTable) {
        LeaseInfo info = leaseTable.get(vmid);
        if (info != null) {
            info.notifySet.remove(target);
        }
    }
}
 
Example #22
Source File: DGCImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Register interest in receiving a callback when this VMID
 * becomes inaccessible.
 */
void registerTarget(VMID vmid, Target target) {
    synchronized (leaseTable) {
        LeaseInfo info = leaseTable.get(vmid);
        if (info == null) {
            target.vmidDead(vmid);
        } else {
            info.notifySet.add(target);
        }
    }
}
 
Example #23
Source File: DGCImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The clean call removes the VMID from the set of clients
 * that hold references to the object associated with the LiveRef
 * ref.  The sequence number is used to detect late clean calls.  If the
 * argument "strong" is true, then the clean call is a result of a
 * failed "dirty" call, thus the sequence number for the VMID needs
 * to be remembered until the client goes away.
 */
public void clean(ObjID[] ids, long sequenceNum, VMID vmid, boolean strong)
{
    for (ObjID id : ids) {
        if (dgcLog.isLoggable(Log.VERBOSE)) {
            dgcLog.log(Log.VERBOSE, "id = " + id +
                ", vmid = " + vmid + ", strong = " + strong);
        }

        ObjectTable.unreferenced(id, sequenceNum, vmid, strong);
    }
}
 
Example #24
Source File: DGCImpl_Stub.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ObjectInputFilter to filter DGCClient return value (a Lease).
 * The list of acceptable classes is very short and explicit.
 * The depth and array sizes are limited.
 * <p>
 * The filter must accept normal and exception returns.
 * A DGC server may throw exceptions that may have a cause
 * and suppressed exceptions.
 *
 * @param filterInfo access to class, arrayLength, etc.
 * @return  {@link ObjectInputFilter.Status#ALLOWED} if allowed,
 *          {@link ObjectInputFilter.Status#REJECTED} if rejected,
 *          otherwise {@link ObjectInputFilter.Status#UNDECIDED}
 */
private static ObjectInputFilter.Status leaseFilter(ObjectInputFilter.FilterInfo filterInfo) {

    if (filterInfo.depth() > DGCCLIENT_MAX_DEPTH) {
        return ObjectInputFilter.Status.REJECTED;
    }
    Class<?> clazz = filterInfo.serialClass();
    if (clazz != null) {
        while (clazz.isArray()) {
            if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > DGCCLIENT_MAX_ARRAY_SIZE) {
                return ObjectInputFilter.Status.REJECTED;
            }
            // Arrays are allowed depending on the component type
            clazz = clazz.getComponentType();
        }
        if (clazz.isPrimitive()) {
            // Arrays of primitives are allowed
            return ObjectInputFilter.Status.ALLOWED;
        }
        return (clazz == UID.class ||
                clazz == VMID.class ||
                clazz == Lease.class ||
                (Throwable.class.isAssignableFrom(clazz) &&
                        clazz.getClassLoader() ==
                        Object.class.getClassLoader()) ||
                clazz == StackTraceElement.class ||
                clazz == ArrayList.class ||     // for suppressed exceptions, if any
                clazz == Object.class ||
                clazz.getName().equals("java.util.Collections$UnmodifiableList") ||
                clazz.getName().equals("java.util.Collections$UnmodifiableCollection") ||
                clazz.getName().equals("java.util.Collections$UnmodifiableRandomAccessList"))
                ? ObjectInputFilter.Status.ALLOWED
                : ObjectInputFilter.Status.REJECTED;
    }
    // Not a class, not size limited
    return ObjectInputFilter.Status.UNDECIDED;
}
 
Example #25
Source File: ObjectTable.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Process client VM dropping reference for given ObjID: forward to
 * corresponding Target entry.  If ObjID is not found in table,
 * no action is taken.
 */
static void unreferenced(ObjID id, long sequenceNum, VMID vmid,
                         boolean strong)
{
    synchronized (tableLock) {
        ObjectEndpoint oe =
            new ObjectEndpoint(id, Transport.currentTransport());
        Target target = objTable.get(oe);
        if (target != null)
            target.unreferenced(sequenceNum, vmid, strong);
    }
}
 
Example #26
Source File: ObjectTable.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Process client VM signalling reference for given ObjID: forward to
 * corresponding Target entry.  If ObjID is not found in table,
 * no action is taken.
 */
static void referenced(ObjID id, long sequenceNum, VMID vmid) {
    synchronized (tableLock) {
        ObjectEndpoint oe =
            new ObjectEndpoint(id, Transport.currentTransport());
        Target target = objTable.get(oe);
        if (target != null) {
            target.referenced(sequenceNum, vmid);
        }
    }
}
 
Example #27
Source File: Target.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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.
 */
synchronized public void vmidDead(VMID vmid) {
    if (DGCImpl.dgcLog.isLoggable(Log.BRIEF)) {
        DGCImpl.dgcLog.log(Log.BRIEF, "removing endpoint " +
                        vmid + " from reference set");
    }

    sequenceTable.remove(vmid);
    refSetRemove(vmid);
}
 
Example #28
Source File: Target.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add an endpoint to the remembered set.  Also adds a notifier
 * to call back if the address space associated with the endpoint
 * dies.
 */
synchronized void referenced(long sequenceNum, VMID vmid) {
    // check sequence number for vmid
    SequenceEntry entry = sequenceTable.get(vmid);
    if (entry == null) {
        sequenceTable.put(vmid, new SequenceEntry(sequenceNum));
    } else if (entry.sequenceNum < sequenceNum) {
        entry.update(sequenceNum);
    } else  {
        // late dirty call; ignore.
        return;
    }

    if (!refSet.contains(vmid)) {
        /*
         * 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();
        if (getImpl() == null)      // too late if impl was collected
            return;

        if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
            DGCImpl.dgcLog.log(Log.VERBOSE, "add to dirty set: " + vmid);
        }

        refSet.addElement(vmid);

        DGCImpl.getDGCImpl().registerTarget(vmid, this);
    }
}
 
Example #29
Source File: DGCImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ObjectInputFilter to filter DGC input objects.
 * The list of acceptable classes is very short and explicit.
 * The depth and array sizes are limited.
 *
 * @param filterInfo access to class, arrayLength, etc.
 * @return  {@link ObjectInputFilter.Status#ALLOWED} if allowed,
 *          {@link ObjectInputFilter.Status#REJECTED} if rejected,
 *          otherwise {@link ObjectInputFilter.Status#UNDECIDED}
 */
private static ObjectInputFilter.Status checkInput(ObjectInputFilter.FilterInfo filterInfo) {
    if (dgcFilter != null) {
        ObjectInputFilter.Status status = dgcFilter.checkInput(filterInfo);
        if (status != ObjectInputFilter.Status.UNDECIDED) {
            // The DGC filter can override the built-in white-list
            return status;
        }
    }

    if (filterInfo.depth() > DGC_MAX_DEPTH) {
        return ObjectInputFilter.Status.REJECTED;
    }
    Class<?> clazz = filterInfo.serialClass();
    if (clazz != null) {
        while (clazz.isArray()) {
            if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > DGC_MAX_ARRAY_SIZE) {
                return ObjectInputFilter.Status.REJECTED;
            }
            // Arrays are allowed depending on the component type
            clazz = clazz.getComponentType();
        }
        if (clazz.isPrimitive()) {
            // Arrays of primitives are allowed
            return ObjectInputFilter.Status.ALLOWED;
        }
        return (clazz == ObjID.class ||
                clazz == UID.class ||
                clazz == VMID.class ||
                clazz == Lease.class)
                ? ObjectInputFilter.Status.ALLOWED
                : ObjectInputFilter.Status.REJECTED;
    }
    // Not a class, not size limited
    return ObjectInputFilter.Status.UNDECIDED;
}
 
Example #30
Source File: Target.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Remove endpoint from the reference set.
 */
synchronized private void refSetRemove(VMID vmid) {
    // remove notification request
    DGCImpl.getDGCImpl().unregisterTarget(vmid, this);

    if (refSet.removeElement(vmid) && refSet.isEmpty()) {
        // reference set is empty, so server can be garbage collected.
        // remove object from table.
        if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
            DGCImpl.dgcLog.log(Log.VERBOSE,
                "reference set is empty: target = " + this);
        }

        /*
         * If the remote object implements the Unreferenced interface,
         * invoke its unreferenced callback in a separate thread.
         */
        Remote obj = getImpl();
        if (obj instanceof Unreferenced) {
            final Unreferenced unrefObj = (Unreferenced) obj;
            AccessController.doPrivileged(
                new NewThreadAction(() -> {
                    Thread.currentThread().setContextClassLoader(ccl);
                    AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
                        unrefObj.unreferenced();
                        return null;
                    }, acc);
                }, "Unreferenced-" + nextThreadNum++, false, true)).start();
                // REMIND: access to nextThreadNum not synchronized; you care?
        }

        unpinImpl();
    }
}