Java Code Examples for sun.jvm.hotspot.oops.Symbol#equals()

The following examples show how to use sun.jvm.hotspot.oops.Symbol#equals() . 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: ArrayTypeImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
boolean isAssignableTo(ReferenceType destType) {
    if (destType instanceof ArrayType) {
        try {
            Type destComponentType = ((ArrayType)destType).componentType();
            return isComponentAssignable(destComponentType, componentType());
        } catch (ClassNotLoadedException e) {
            // One or both component types has not yet been
            // loaded => can't assign
            return false;
        }
    } else {
        Symbol typeName = ((ReferenceTypeImpl)destType).typeNameAsSymbol();
        if (destType instanceof InterfaceType) {
            // Every array type implements java.io.Serializable and
            // java.lang.Cloneable. fixme in JVMDI-JDI, includes only
            // Cloneable but not Serializable.
            return typeName.equals(vm.javaLangCloneable()) ||
                   typeName.equals(vm.javaIoSerializable());
        } else {
            // Only valid ClassType assignee is Object
            return typeName.equals(vm.javaLangObject());
        }
    }
}
 
Example 2
Source File: ArrayTypeImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
boolean isAssignableTo(ReferenceType destType) {
    if (destType instanceof ArrayType) {
        try {
            Type destComponentType = ((ArrayType)destType).componentType();
            return isComponentAssignable(destComponentType, componentType());
        } catch (ClassNotLoadedException e) {
            // One or both component types has not yet been
            // loaded => can't assign
            return false;
        }
    } else {
        Symbol typeName = ((ReferenceTypeImpl)destType).typeNameAsSymbol();
        if (destType instanceof InterfaceType) {
            // Every array type implements java.io.Serializable and
            // java.lang.Cloneable. fixme in JVMDI-JDI, includes only
            // Cloneable but not Serializable.
            return typeName.equals(vm.javaLangCloneable()) ||
                   typeName.equals(vm.javaIoSerializable());
        } else {
            // Only valid ClassType assignee is Object
            return typeName.equals(vm.javaLangObject());
        }
    }
}
 
Example 3
Source File: ArrayTypeImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
boolean isAssignableTo(ReferenceType destType) {
    if (destType instanceof ArrayType) {
        try {
            Type destComponentType = ((ArrayType)destType).componentType();
            return isComponentAssignable(destComponentType, componentType());
        } catch (ClassNotLoadedException e) {
            // One or both component types has not yet been
            // loaded => can't assign
            return false;
        }
    } else {
        Symbol typeName = ((ReferenceTypeImpl)destType).typeNameAsSymbol();
        if (destType instanceof InterfaceType) {
            // Every array type implements java.io.Serializable and
            // java.lang.Cloneable. fixme in JVMDI-JDI, includes only
            // Cloneable but not Serializable.
            return typeName.equals(vm.javaLangCloneable()) ||
                   typeName.equals(vm.javaIoSerializable());
        } else {
            // Only valid ClassType assignee is Object
            return typeName.equals(vm.javaLangObject());
        }
    }
}
 
Example 4
Source File: ArrayTypeImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
boolean isAssignableTo(ReferenceType destType) {
    if (destType instanceof ArrayType) {
        try {
            Type destComponentType = ((ArrayType)destType).componentType();
            return isComponentAssignable(destComponentType, componentType());
        } catch (ClassNotLoadedException e) {
            // One or both component types has not yet been
            // loaded => can't assign
            return false;
        }
    } else {
        Symbol typeName = ((ReferenceTypeImpl)destType).typeNameAsSymbol();
        if (destType instanceof InterfaceType) {
            // Every array type implements java.io.Serializable and
            // java.lang.Cloneable. fixme in JVMDI-JDI, includes only
            // Cloneable but not Serializable.
            return typeName.equals(vm.javaLangCloneable()) ||
                   typeName.equals(vm.javaIoSerializable());
        } else {
            // Only valid ClassType assignee is Object
            return typeName.equals(vm.javaLangObject());
        }
    }
}
 
Example 5
Source File: ArrayTypeImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
boolean isAssignableTo(ReferenceType destType) {
    if (destType instanceof ArrayType) {
        try {
            Type destComponentType = ((ArrayType)destType).componentType();
            return isComponentAssignable(destComponentType, componentType());
        } catch (ClassNotLoadedException e) {
            // One or both component types has not yet been
            // loaded => can't assign
            return false;
        }
    } else {
        Symbol typeName = ((ReferenceTypeImpl)destType).typeNameAsSymbol();
        if (destType instanceof InterfaceType) {
            // Every array type implements java.io.Serializable and
            // java.lang.Cloneable. fixme in JVMDI-JDI, includes only
            // Cloneable but not Serializable.
            return typeName.equals(vm.javaLangCloneable()) ||
                   typeName.equals(vm.javaIoSerializable());
        } else {
            // Only valid ClassType assignee is Object
            return typeName.equals(vm.javaLangObject());
        }
    }
}
 
Example 6
Source File: ArrayTypeImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
boolean isAssignableTo(ReferenceType destType) {
    if (destType instanceof ArrayType) {
        try {
            Type destComponentType = ((ArrayType)destType).componentType();
            return isComponentAssignable(destComponentType, componentType());
        } catch (ClassNotLoadedException e) {
            // One or both component types has not yet been
            // loaded => can't assign
            return false;
        }
    } else {
        Symbol typeName = ((ReferenceTypeImpl)destType).typeNameAsSymbol();
        if (destType instanceof InterfaceType) {
            // Every array type implements java.io.Serializable and
            // java.lang.Cloneable. fixme in JVMDI-JDI, includes only
            // Cloneable but not Serializable.
            return typeName.equals(vm.javaLangCloneable()) ||
                   typeName.equals(vm.javaIoSerializable());
        } else {
            // Only valid ClassType assignee is Object
            return typeName.equals(vm.javaLangObject());
        }
    }
}
 
Example 7
Source File: ArrayTypeImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
boolean isAssignableTo(ReferenceType destType) {
    if (destType instanceof ArrayType) {
        try {
            Type destComponentType = ((ArrayType)destType).componentType();
            return isComponentAssignable(destComponentType, componentType());
        } catch (ClassNotLoadedException e) {
            // One or both component types has not yet been
            // loaded => can't assign
            return false;
        }
    } else {
        Symbol typeName = ((ReferenceTypeImpl)destType).typeNameAsSymbol();
        if (destType instanceof InterfaceType) {
            // Every array type implements java.io.Serializable and
            // java.lang.Cloneable. fixme in JVMDI-JDI, includes only
            // Cloneable but not Serializable.
            return typeName.equals(vm.javaLangCloneable()) ||
                   typeName.equals(vm.javaIoSerializable());
        } else {
            // Only valid ClassType assignee is Object
            return typeName.equals(vm.javaLangObject());
        }
    }
}
 
Example 8
Source File: VirtualMachineImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private synchronized List findReferenceTypes(String signature) {
    if (typesByID == null) {
        return new ArrayList(0);
    }

    // we haven't sorted types by signatures. But we can take
    // advantage of comparing symbols instead of name. In the worst
    // case, we will be comparing N addresses rather than N strings
    // where N being total no. of classes in allClasses() list.

    // The signature could be Lx/y/z; or [....
    // If it is Lx/y/z; the internal type name is x/y/x
    // for array klasses internal type name is same as
    // signature
    String typeName = null;
    if (signature.charAt(0) == 'L') {
        typeName = signature.substring(1, signature.length() - 1);
    } else {
        typeName = signature;
    }

    Symbol typeNameSym = saSymbolTable().probe(typeName);
    // if there is no symbol in VM, then we wouldn't have that type
    if (typeNameSym == null) {
        return new ArrayList(0);
    }

    Iterator iter = typesBySignature.iterator();
    List list = new ArrayList();
    while (iter.hasNext()) {
        // We have cached type name as symbol in reference type
        ReferenceTypeImpl type = (ReferenceTypeImpl)iter.next();
        if (typeNameSym.equals(type.typeNameAsSymbol())) {
            list.add(type);
        }
    }
    return list;
}
 
Example 9
Source File: VirtualMachineImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private synchronized List findReferenceTypes(String signature) {
    if (typesByID == null) {
        return new ArrayList(0);
    }

    // we haven't sorted types by signatures. But we can take
    // advantage of comparing symbols instead of name. In the worst
    // case, we will be comparing N addresses rather than N strings
    // where N being total no. of classes in allClasses() list.

    // The signature could be Lx/y/z; or [....
    // If it is Lx/y/z; the internal type name is x/y/x
    // for array klasses internal type name is same as
    // signature
    String typeName = null;
    if (signature.charAt(0) == 'L') {
        typeName = signature.substring(1, signature.length() - 1);
    } else {
        typeName = signature;
    }

    Symbol typeNameSym = saSymbolTable().probe(typeName);
    // if there is no symbol in VM, then we wouldn't have that type
    if (typeNameSym == null) {
        return new ArrayList(0);
    }

    Iterator iter = typesBySignature.iterator();
    List list = new ArrayList();
    while (iter.hasNext()) {
        // We have cached type name as symbol in reference type
        ReferenceTypeImpl type = (ReferenceTypeImpl)iter.next();
        if (typeNameSym.equals(type.typeNameAsSymbol())) {
            list.add(type);
        }
    }
    return list;
}
 
Example 10
Source File: VirtualMachineImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private synchronized List findReferenceTypes(String signature) {
    if (typesByID == null) {
        return new ArrayList(0);
    }

    // we haven't sorted types by signatures. But we can take
    // advantage of comparing symbols instead of name. In the worst
    // case, we will be comparing N addresses rather than N strings
    // where N being total no. of classes in allClasses() list.

    // The signature could be Lx/y/z; or [....
    // If it is Lx/y/z; the internal type name is x/y/x
    // for array klasses internal type name is same as
    // signature
    String typeName = null;
    if (signature.charAt(0) == 'L') {
        typeName = signature.substring(1, signature.length() - 1);
    } else {
        typeName = signature;
    }

    Symbol typeNameSym = saSymbolTable().probe(typeName);
    // if there is no symbol in VM, then we wouldn't have that type
    if (typeNameSym == null) {
        return new ArrayList(0);
    }

    Iterator iter = typesBySignature.iterator();
    List list = new ArrayList();
    while (iter.hasNext()) {
        // We have cached type name as symbol in reference type
        ReferenceTypeImpl type = (ReferenceTypeImpl)iter.next();
        if (typeNameSym.equals(type.typeNameAsSymbol())) {
            list.add(type);
        }
    }
    return list;
}
 
Example 11
Source File: VirtualMachineImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private synchronized List findReferenceTypes(String signature) {
    if (typesByID == null) {
        return new ArrayList(0);
    }

    // we haven't sorted types by signatures. But we can take
    // advantage of comparing symbols instead of name. In the worst
    // case, we will be comparing N addresses rather than N strings
    // where N being total no. of classes in allClasses() list.

    // The signature could be Lx/y/z; or [....
    // If it is Lx/y/z; the internal type name is x/y/x
    // for array klasses internal type name is same as
    // signature
    String typeName = null;
    if (signature.charAt(0) == 'L') {
        typeName = signature.substring(1, signature.length() - 1);
    } else {
        typeName = signature;
    }

    Symbol typeNameSym = saSymbolTable().probe(typeName);
    // if there is no symbol in VM, then we wouldn't have that type
    if (typeNameSym == null) {
        return new ArrayList(0);
    }

    Iterator iter = typesBySignature.iterator();
    List list = new ArrayList();
    while (iter.hasNext()) {
        // We have cached type name as symbol in reference type
        ReferenceTypeImpl type = (ReferenceTypeImpl)iter.next();
        if (typeNameSym.equals(type.typeNameAsSymbol())) {
            list.add(type);
        }
    }
    return list;
}
 
Example 12
Source File: VirtualMachineImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private synchronized List findReferenceTypes(String signature) {
    if (typesByID == null) {
        return new ArrayList(0);
    }

    // we haven't sorted types by signatures. But we can take
    // advantage of comparing symbols instead of name. In the worst
    // case, we will be comparing N addresses rather than N strings
    // where N being total no. of classes in allClasses() list.

    // The signature could be Lx/y/z; or [....
    // If it is Lx/y/z; the internal type name is x/y/x
    // for array klasses internal type name is same as
    // signature
    String typeName = null;
    if (signature.charAt(0) == 'L') {
        typeName = signature.substring(1, signature.length() - 1);
    } else {
        typeName = signature;
    }

    Symbol typeNameSym = saSymbolTable().probe(typeName);
    // if there is no symbol in VM, then we wouldn't have that type
    if (typeNameSym == null) {
        return new ArrayList(0);
    }

    Iterator iter = typesBySignature.iterator();
    List list = new ArrayList();
    while (iter.hasNext()) {
        // We have cached type name as symbol in reference type
        ReferenceTypeImpl type = (ReferenceTypeImpl)iter.next();
        if (typeNameSym.equals(type.typeNameAsSymbol())) {
            list.add(type);
        }
    }
    return list;
}
 
Example 13
Source File: VirtualMachineImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private synchronized List findReferenceTypes(String signature) {
    if (typesByID == null) {
        return new ArrayList(0);
    }

    // we haven't sorted types by signatures. But we can take
    // advantage of comparing symbols instead of name. In the worst
    // case, we will be comparing N addresses rather than N strings
    // where N being total no. of classes in allClasses() list.

    // The signature could be Lx/y/z; or [....
    // If it is Lx/y/z; the internal type name is x/y/x
    // for array klasses internal type name is same as
    // signature
    String typeName = null;
    if (signature.charAt(0) == 'L') {
        typeName = signature.substring(1, signature.length() - 1);
    } else {
        typeName = signature;
    }

    Symbol typeNameSym = saSymbolTable().probe(typeName);
    // if there is no symbol in VM, then we wouldn't have that type
    if (typeNameSym == null) {
        return new ArrayList(0);
    }

    Iterator iter = typesBySignature.iterator();
    List list = new ArrayList();
    while (iter.hasNext()) {
        // We have cached type name as symbol in reference type
        ReferenceTypeImpl type = (ReferenceTypeImpl)iter.next();
        if (typeNameSym.equals(type.typeNameAsSymbol())) {
            list.add(type);
        }
    }
    return list;
}
 
Example 14
Source File: VirtualMachineImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private synchronized List findReferenceTypes(String signature) {
    if (typesByID == null) {
        return new ArrayList(0);
    }

    // we haven't sorted types by signatures. But we can take
    // advantage of comparing symbols instead of name. In the worst
    // case, we will be comparing N addresses rather than N strings
    // where N being total no. of classes in allClasses() list.

    // The signature could be Lx/y/z; or [....
    // If it is Lx/y/z; the internal type name is x/y/x
    // for array klasses internal type name is same as
    // signature
    String typeName = null;
    if (signature.charAt(0) == 'L') {
        typeName = signature.substring(1, signature.length() - 1);
    } else {
        typeName = signature;
    }

    Symbol typeNameSym = saSymbolTable().probe(typeName);
    // if there is no symbol in VM, then we wouldn't have that type
    if (typeNameSym == null) {
        return new ArrayList(0);
    }

    Iterator iter = typesBySignature.iterator();
    List list = new ArrayList();
    while (iter.hasNext()) {
        // We have cached type name as symbol in reference type
        ReferenceTypeImpl type = (ReferenceTypeImpl)iter.next();
        if (typeNameSym.equals(type.typeNameAsSymbol())) {
            list.add(type);
        }
    }
    return list;
}
 
Example 15
Source File: VirtualMachineImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
synchronized ObjectReferenceImpl objectMirror(Oop key) {

        // Handle any queue elements that are not strongly reachable
        processQueue();

        if (key == null) {
            return null;
        }
        ObjectReferenceImpl object = null;

        /*
         * Attempt to retrieve an existing object object reference
         */
        SoftObjectReference ref = (SoftObjectReference)objectsByID.get(key);
        if (ref != null) {
            object = ref.object();
        }

        /*
         * If the object wasn't in the table, or it's soft reference was
         * cleared, create a new instance.
         */
        if (object == null) {
            if (key instanceof Instance) {
                // look for well-known classes
                Symbol className = key.getKlass().getName();
                if (Assert.ASSERTS_ENABLED) {
                    Assert.that(className != null, "Null class name");
                }
                Instance inst = (Instance) key;
                if (className.equals(javaLangString)) {
                    object = new StringReferenceImpl(this, inst);
                } else if (className.equals(javaLangThread)) {
                    object = new ThreadReferenceImpl(this, inst);
                } else if (className.equals(javaLangThreadGroup)) {
                    object = new ThreadGroupReferenceImpl(this, inst);
                } else if (className.equals(javaLangClass)) {
                    object = new ClassObjectReferenceImpl(this, inst);
                } else if (className.equals(javaLangClassLoader)) {
                    object = new ClassLoaderReferenceImpl(this, inst);
                } else {
                    // not a well-known class. But the base class may be
                    // one of the known classes.
                    Klass kls = key.getKlass().getSuper();
                    while (kls != null) {
                       className = kls.getName();
                       // java.lang.Class and java.lang.String are final classes
                       if (className.equals(javaLangThread)) {
                          object = new ThreadReferenceImpl(this, inst);
                          break;
                       } else if(className.equals(javaLangThreadGroup)) {
                          object = new ThreadGroupReferenceImpl(this, inst);
                          break;
                       } else if (className.equals(javaLangClassLoader)) {
                          object = new ClassLoaderReferenceImpl(this, inst);
                          break;
                       }
                       kls = kls.getSuper();
                    }

                    if (object == null) {
                       // create generic object reference
                       object = new ObjectReferenceImpl(this, inst);
                    }
                }
            } else if (key instanceof TypeArray) {
                object = new ArrayReferenceImpl(this, (Array) key);
            } else if (key instanceof ObjArray) {
                object = new ArrayReferenceImpl(this, (Array) key);
            } else {
                throw new RuntimeException("unexpected object type " + key);
            }
            ref = new SoftObjectReference(key, object, referenceQueue);

            /*
             * If there was no previous entry in the table, we add one here
             * If the previous entry was cleared, we replace it here.
             */
            objectsByID.put(key, ref);
        } else {
            ref.incrementCount();
        }

        return object;
    }
 
Example 16
Source File: VirtualMachineImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
synchronized ObjectReferenceImpl objectMirror(Oop key) {

        // Handle any queue elements that are not strongly reachable
        processQueue();

        if (key == null) {
            return null;
        }
        ObjectReferenceImpl object = null;

        /*
         * Attempt to retrieve an existing object object reference
         */
        SoftObjectReference ref = (SoftObjectReference)objectsByID.get(key);
        if (ref != null) {
            object = ref.object();
        }

        /*
         * If the object wasn't in the table, or it's soft reference was
         * cleared, create a new instance.
         */
        if (object == null) {
            if (key instanceof Instance) {
                // look for well-known classes
                Symbol className = key.getKlass().getName();
                if (Assert.ASSERTS_ENABLED) {
                    Assert.that(className != null, "Null class name");
                }
                Instance inst = (Instance) key;
                if (className.equals(javaLangString)) {
                    object = new StringReferenceImpl(this, inst);
                } else if (className.equals(javaLangThread)) {
                    object = new ThreadReferenceImpl(this, inst);
                } else if (className.equals(javaLangThreadGroup)) {
                    object = new ThreadGroupReferenceImpl(this, inst);
                } else if (className.equals(javaLangClass)) {
                    object = new ClassObjectReferenceImpl(this, inst);
                } else if (className.equals(javaLangClassLoader)) {
                    object = new ClassLoaderReferenceImpl(this, inst);
                } else {
                    // not a well-known class. But the base class may be
                    // one of the known classes.
                    Klass kls = key.getKlass().getSuper();
                    while (kls != null) {
                       className = kls.getName();
                       // java.lang.Class and java.lang.String are final classes
                       if (className.equals(javaLangThread)) {
                          object = new ThreadReferenceImpl(this, inst);
                          break;
                       } else if(className.equals(javaLangThreadGroup)) {
                          object = new ThreadGroupReferenceImpl(this, inst);
                          break;
                       } else if (className.equals(javaLangClassLoader)) {
                          object = new ClassLoaderReferenceImpl(this, inst);
                          break;
                       }
                       kls = kls.getSuper();
                    }

                    if (object == null) {
                       // create generic object reference
                       object = new ObjectReferenceImpl(this, inst);
                    }
                }
            } else if (key instanceof TypeArray) {
                object = new ArrayReferenceImpl(this, (Array) key);
            } else if (key instanceof ObjArray) {
                object = new ArrayReferenceImpl(this, (Array) key);
            } else {
                throw new RuntimeException("unexpected object type " + key);
            }
            ref = new SoftObjectReference(key, object, referenceQueue);

            /*
             * If there was no previous entry in the table, we add one here
             * If the previous entry was cleared, we replace it here.
             */
            objectsByID.put(key, ref);
        } else {
            ref.incrementCount();
        }

        return object;
    }
 
Example 17
Source File: VirtualMachineImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
synchronized ObjectReferenceImpl objectMirror(Oop key) {

        // Handle any queue elements that are not strongly reachable
        processQueue();

        if (key == null) {
            return null;
        }
        ObjectReferenceImpl object = null;

        /*
         * Attempt to retrieve an existing object object reference
         */
        SoftObjectReference ref = (SoftObjectReference)objectsByID.get(key);
        if (ref != null) {
            object = ref.object();
        }

        /*
         * If the object wasn't in the table, or it's soft reference was
         * cleared, create a new instance.
         */
        if (object == null) {
            if (key instanceof Instance) {
                // look for well-known classes
                Symbol className = key.getKlass().getName();
                if (Assert.ASSERTS_ENABLED) {
                    Assert.that(className != null, "Null class name");
                }
                Instance inst = (Instance) key;
                if (className.equals(javaLangString)) {
                    object = new StringReferenceImpl(this, inst);
                } else if (className.equals(javaLangThread)) {
                    object = new ThreadReferenceImpl(this, inst);
                } else if (className.equals(javaLangThreadGroup)) {
                    object = new ThreadGroupReferenceImpl(this, inst);
                } else if (className.equals(javaLangClass)) {
                    object = new ClassObjectReferenceImpl(this, inst);
                } else if (className.equals(javaLangClassLoader)) {
                    object = new ClassLoaderReferenceImpl(this, inst);
                } else {
                    // not a well-known class. But the base class may be
                    // one of the known classes.
                    Klass kls = key.getKlass().getSuper();
                    while (kls != null) {
                       className = kls.getName();
                       // java.lang.Class and java.lang.String are final classes
                       if (className.equals(javaLangThread)) {
                          object = new ThreadReferenceImpl(this, inst);
                          break;
                       } else if(className.equals(javaLangThreadGroup)) {
                          object = new ThreadGroupReferenceImpl(this, inst);
                          break;
                       } else if (className.equals(javaLangClassLoader)) {
                          object = new ClassLoaderReferenceImpl(this, inst);
                          break;
                       }
                       kls = kls.getSuper();
                    }

                    if (object == null) {
                       // create generic object reference
                       object = new ObjectReferenceImpl(this, inst);
                    }
                }
            } else if (key instanceof TypeArray) {
                object = new ArrayReferenceImpl(this, (Array) key);
            } else if (key instanceof ObjArray) {
                object = new ArrayReferenceImpl(this, (Array) key);
            } else {
                throw new RuntimeException("unexpected object type " + key);
            }
            ref = new SoftObjectReference(key, object, referenceQueue);

            /*
             * If there was no previous entry in the table, we add one here
             * If the previous entry was cleared, we replace it here.
             */
            objectsByID.put(key, ref);
        } else {
            ref.incrementCount();
        }

        return object;
    }
 
Example 18
Source File: VirtualMachineImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
synchronized ObjectReferenceImpl objectMirror(Oop key) {

        // Handle any queue elements that are not strongly reachable
        processQueue();

        if (key == null) {
            return null;
        }
        ObjectReferenceImpl object = null;

        /*
         * Attempt to retrieve an existing object object reference
         */
        SoftObjectReference ref = (SoftObjectReference)objectsByID.get(key);
        if (ref != null) {
            object = ref.object();
        }

        /*
         * If the object wasn't in the table, or it's soft reference was
         * cleared, create a new instance.
         */
        if (object == null) {
            if (key instanceof Instance) {
                // look for well-known classes
                Symbol className = key.getKlass().getName();
                if (Assert.ASSERTS_ENABLED) {
                    Assert.that(className != null, "Null class name");
                }
                Instance inst = (Instance) key;
                if (className.equals(javaLangString)) {
                    object = new StringReferenceImpl(this, inst);
                } else if (className.equals(javaLangThread)) {
                    object = new ThreadReferenceImpl(this, inst);
                } else if (className.equals(javaLangThreadGroup)) {
                    object = new ThreadGroupReferenceImpl(this, inst);
                } else if (className.equals(javaLangClass)) {
                    object = new ClassObjectReferenceImpl(this, inst);
                } else if (className.equals(javaLangClassLoader)) {
                    object = new ClassLoaderReferenceImpl(this, inst);
                } else {
                    // not a well-known class. But the base class may be
                    // one of the known classes.
                    Klass kls = key.getKlass().getSuper();
                    while (kls != null) {
                       className = kls.getName();
                       // java.lang.Class and java.lang.String are final classes
                       if (className.equals(javaLangThread)) {
                          object = new ThreadReferenceImpl(this, inst);
                          break;
                       } else if(className.equals(javaLangThreadGroup)) {
                          object = new ThreadGroupReferenceImpl(this, inst);
                          break;
                       } else if (className.equals(javaLangClassLoader)) {
                          object = new ClassLoaderReferenceImpl(this, inst);
                          break;
                       }
                       kls = kls.getSuper();
                    }

                    if (object == null) {
                       // create generic object reference
                       object = new ObjectReferenceImpl(this, inst);
                    }
                }
            } else if (key instanceof TypeArray) {
                object = new ArrayReferenceImpl(this, (Array) key);
            } else if (key instanceof ObjArray) {
                object = new ArrayReferenceImpl(this, (Array) key);
            } else {
                throw new RuntimeException("unexpected object type " + key);
            }
            ref = new SoftObjectReference(key, object, referenceQueue);

            /*
             * If there was no previous entry in the table, we add one here
             * If the previous entry was cleared, we replace it here.
             */
            objectsByID.put(key, ref);
        } else {
            ref.incrementCount();
        }

        return object;
    }
 
Example 19
Source File: VirtualMachineImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
synchronized ObjectReferenceImpl objectMirror(Oop key) {

        // Handle any queue elements that are not strongly reachable
        processQueue();

        if (key == null) {
            return null;
        }
        ObjectReferenceImpl object = null;

        /*
         * Attempt to retrieve an existing object object reference
         */
        SoftObjectReference ref = (SoftObjectReference)objectsByID.get(key);
        if (ref != null) {
            object = ref.object();
        }

        /*
         * If the object wasn't in the table, or it's soft reference was
         * cleared, create a new instance.
         */
        if (object == null) {
            if (key instanceof Instance) {
                // look for well-known classes
                Symbol className = key.getKlass().getName();
                if (Assert.ASSERTS_ENABLED) {
                    Assert.that(className != null, "Null class name");
                }
                Instance inst = (Instance) key;
                if (className.equals(javaLangString)) {
                    object = new StringReferenceImpl(this, inst);
                } else if (className.equals(javaLangThread)) {
                    object = new ThreadReferenceImpl(this, inst);
                } else if (className.equals(javaLangThreadGroup)) {
                    object = new ThreadGroupReferenceImpl(this, inst);
                } else if (className.equals(javaLangClass)) {
                    object = new ClassObjectReferenceImpl(this, inst);
                } else if (className.equals(javaLangClassLoader)) {
                    object = new ClassLoaderReferenceImpl(this, inst);
                } else {
                    // not a well-known class. But the base class may be
                    // one of the known classes.
                    Klass kls = key.getKlass().getSuper();
                    while (kls != null) {
                       className = kls.getName();
                       // java.lang.Class and java.lang.String are final classes
                       if (className.equals(javaLangThread)) {
                          object = new ThreadReferenceImpl(this, inst);
                          break;
                       } else if(className.equals(javaLangThreadGroup)) {
                          object = new ThreadGroupReferenceImpl(this, inst);
                          break;
                       } else if (className.equals(javaLangClassLoader)) {
                          object = new ClassLoaderReferenceImpl(this, inst);
                          break;
                       }
                       kls = kls.getSuper();
                    }

                    if (object == null) {
                       // create generic object reference
                       object = new ObjectReferenceImpl(this, inst);
                    }
                }
            } else if (key instanceof TypeArray) {
                object = new ArrayReferenceImpl(this, (Array) key);
            } else if (key instanceof ObjArray) {
                object = new ArrayReferenceImpl(this, (Array) key);
            } else {
                throw new RuntimeException("unexpected object type " + key);
            }
            ref = new SoftObjectReference(key, object, referenceQueue);

            /*
             * If there was no previous entry in the table, we add one here
             * If the previous entry was cleared, we replace it here.
             */
            objectsByID.put(key, ref);
        } else {
            ref.incrementCount();
        }

        return object;
    }
 
Example 20
Source File: VirtualMachineImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
synchronized ObjectReferenceImpl objectMirror(Oop key) {

        // Handle any queue elements that are not strongly reachable
        processQueue();

        if (key == null) {
            return null;
        }
        ObjectReferenceImpl object = null;

        /*
         * Attempt to retrieve an existing object object reference
         */
        SoftObjectReference ref = (SoftObjectReference)objectsByID.get(key);
        if (ref != null) {
            object = ref.object();
        }

        /*
         * If the object wasn't in the table, or it's soft reference was
         * cleared, create a new instance.
         */
        if (object == null) {
            if (key instanceof Instance) {
                // look for well-known classes
                Symbol className = key.getKlass().getName();
                if (Assert.ASSERTS_ENABLED) {
                    Assert.that(className != null, "Null class name");
                }
                Instance inst = (Instance) key;
                if (className.equals(javaLangString)) {
                    object = new StringReferenceImpl(this, inst);
                } else if (className.equals(javaLangThread)) {
                    object = new ThreadReferenceImpl(this, inst);
                } else if (className.equals(javaLangThreadGroup)) {
                    object = new ThreadGroupReferenceImpl(this, inst);
                } else if (className.equals(javaLangClass)) {
                    object = new ClassObjectReferenceImpl(this, inst);
                } else if (className.equals(javaLangClassLoader)) {
                    object = new ClassLoaderReferenceImpl(this, inst);
                } else {
                    // not a well-known class. But the base class may be
                    // one of the known classes.
                    Klass kls = key.getKlass().getSuper();
                    while (kls != null) {
                       className = kls.getName();
                       // java.lang.Class and java.lang.String are final classes
                       if (className.equals(javaLangThread)) {
                          object = new ThreadReferenceImpl(this, inst);
                          break;
                       } else if(className.equals(javaLangThreadGroup)) {
                          object = new ThreadGroupReferenceImpl(this, inst);
                          break;
                       } else if (className.equals(javaLangClassLoader)) {
                          object = new ClassLoaderReferenceImpl(this, inst);
                          break;
                       }
                       kls = kls.getSuper();
                    }

                    if (object == null) {
                       // create generic object reference
                       object = new ObjectReferenceImpl(this, inst);
                    }
                }
            } else if (key instanceof TypeArray) {
                object = new ArrayReferenceImpl(this, (Array) key);
            } else if (key instanceof ObjArray) {
                object = new ArrayReferenceImpl(this, (Array) key);
            } else {
                throw new RuntimeException("unexpected object type " + key);
            }
            ref = new SoftObjectReference(key, object, referenceQueue);

            /*
             * If there was no previous entry in the table, we add one here
             * If the previous entry was cleared, we replace it here.
             */
            objectsByID.put(key, ref);
        } else {
            ref.incrementCount();
        }

        return object;
    }