Java Code Examples for com.sun.corba.se.impl.util.Utility#loadStubClass()

The following examples show how to use com.sun.corba.se.impl.util.Utility#loadStubClass() . 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: IIOPInputStream.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Factored out of inputClassFields and reused in
 * inputCurrentClassFieldsForReadFields.
 *
 * Reads the field (which of an Object type as opposed to a primitive)
 * described by ObjectStreamField field and returns it.
 */
private Object inputObjectField(ObjectStreamField field)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IndirectionException, IOException {

    if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
        return javax.rmi.CORBA.Util.readAny(orbStream);
    }

    Object objectValue = null;

    // fields have an API to provide the actual class
    // corresponding to the data type
    // Class type = osc.forClass();
    Class fieldType = field.getType();
    Class actualType = fieldType; // This may change if stub loaded.

    // Decide what method call to make based on the fieldType. If
    // it is a type for which we need to load a stub, convert
    // the type to the correct stub type.

    int callType = ValueHandlerImpl.kValueType;
    boolean narrow = false;

    if (fieldType.isInterface()) {
        boolean loadStubClass = false;

        if (java.rmi.Remote.class.isAssignableFrom(fieldType)) {

            // RMI Object reference...
            callType = ValueHandlerImpl.kRemoteType;

        } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){

            // IDL Object reference...
            callType = ValueHandlerImpl.kRemoteType;
            loadStubClass = true;

        } else if (vhandler.isAbstractBase(fieldType)) {
            // IDL Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
            loadStubClass = true;
        } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) {
            // RMI Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
        }

        if (loadStubClass) {
            try {
                String codebase = Util.getCodebase(fieldType);
                String repID = vhandler.createForAnyType(fieldType);
                Class stubType =
                    Utility.loadStubClass(repID, codebase, fieldType);
                actualType = stubType;
            } catch (ClassNotFoundException e) {
                narrow = true;
            }
        } else {
            narrow = true;
        }
    }

    switch (callType) {
        case ValueHandlerImpl.kRemoteType:
            if (!narrow)
                objectValue = (Object)orbStream.read_Object(actualType);
            else
                objectValue = Utility.readObjectAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kAbstractType:
            if (!narrow)
                objectValue = (Object)orbStream.read_abstract_interface(actualType);
            else
                objectValue = Utility.readAbstractAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kValueType:
            objectValue = (Object)orbStream.read_value(actualType);
            break;
        default:
            // XXX I18N, logging needed.
            throw new StreamCorruptedException("Unknown callType: " + callType);
    }

    return objectValue;
}
 
Example 2
Source File: IIOPInputStream.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Factored out of inputClassFields and reused in
 * inputCurrentClassFieldsForReadFields.
 *
 * Reads the field (which of an Object type as opposed to a primitive)
 * described by ObjectStreamField field and returns it.
 */
private Object inputObjectField(ObjectStreamField field)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IndirectionException, IOException {

    if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
        return javax.rmi.CORBA.Util.readAny(orbStream);
    }

    Object objectValue = null;

    // fields have an API to provide the actual class
    // corresponding to the data type
    // Class type = osc.forClass();
    Class fieldType = field.getType();
    Class actualType = fieldType; // This may change if stub loaded.

    // Decide what method call to make based on the fieldType. If
    // it is a type for which we need to load a stub, convert
    // the type to the correct stub type.

    int callType = ValueHandlerImpl.kValueType;
    boolean narrow = false;

    if (fieldType.isInterface()) {
        boolean loadStubClass = false;

        if (java.rmi.Remote.class.isAssignableFrom(fieldType)) {

            // RMI Object reference...
            callType = ValueHandlerImpl.kRemoteType;

        } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){

            // IDL Object reference...
            callType = ValueHandlerImpl.kRemoteType;
            loadStubClass = true;

        } else if (vhandler.isAbstractBase(fieldType)) {
            // IDL Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
            loadStubClass = true;
        } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) {
            // RMI Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
        }

        if (loadStubClass) {
            try {
                String codebase = Util.getCodebase(fieldType);
                String repID = vhandler.createForAnyType(fieldType);
                Class stubType =
                    Utility.loadStubClass(repID, codebase, fieldType);
                actualType = stubType;
            } catch (ClassNotFoundException e) {
                narrow = true;
            }
        } else {
            narrow = true;
        }
    }

    switch (callType) {
        case ValueHandlerImpl.kRemoteType:
            if (!narrow)
                objectValue = (Object)orbStream.read_Object(actualType);
            else
                objectValue = Utility.readObjectAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kAbstractType:
            if (!narrow)
                objectValue = (Object)orbStream.read_abstract_interface(actualType);
            else
                objectValue = Utility.readAbstractAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kValueType:
            objectValue = (Object)orbStream.read_value(actualType);
            break;
        default:
            // XXX I18N, logging needed.
            throw new StreamCorruptedException("Unknown callType: " + callType);
    }

    return objectValue;
}
 
Example 3
Source File: IIOPInputStream.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Factored out of inputClassFields and reused in
 * inputCurrentClassFieldsForReadFields.
 *
 * Reads the field (which of an Object type as opposed to a primitive)
 * described by ObjectStreamField field and returns it.
 */
private Object inputObjectField(ObjectStreamField field)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IndirectionException, IOException {

    if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
        return javax.rmi.CORBA.Util.readAny(orbStream);
    }

    Object objectValue = null;

    // fields have an API to provide the actual class
    // corresponding to the data type
    // Class type = osc.forClass();
    Class fieldType = field.getType();
    Class actualType = fieldType; // This may change if stub loaded.

    // Decide what method call to make based on the fieldType. If
    // it is a type for which we need to load a stub, convert
    // the type to the correct stub type.

    int callType = ValueHandlerImpl.kValueType;
    boolean narrow = false;

    if (fieldType.isInterface()) {
        boolean loadStubClass = false;

        if (java.rmi.Remote.class.isAssignableFrom(fieldType)) {

            // RMI Object reference...
            callType = ValueHandlerImpl.kRemoteType;

        } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){

            // IDL Object reference...
            callType = ValueHandlerImpl.kRemoteType;
            loadStubClass = true;

        } else if (vhandler.isAbstractBase(fieldType)) {
            // IDL Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
            loadStubClass = true;
        } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) {
            // RMI Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
        }

        if (loadStubClass) {
            try {
                String codebase = Util.getCodebase(fieldType);
                String repID = vhandler.createForAnyType(fieldType);
                Class stubType =
                    Utility.loadStubClass(repID, codebase, fieldType);
                actualType = stubType;
            } catch (ClassNotFoundException e) {
                narrow = true;
            }
        } else {
            narrow = true;
        }
    }

    switch (callType) {
        case ValueHandlerImpl.kRemoteType:
            if (!narrow)
                objectValue = (Object)orbStream.read_Object(actualType);
            else
                objectValue = Utility.readObjectAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kAbstractType:
            if (!narrow)
                objectValue = (Object)orbStream.read_abstract_interface(actualType);
            else
                objectValue = Utility.readAbstractAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kValueType:
            objectValue = (Object)orbStream.read_value(actualType);
            break;
        default:
            // XXX I18N, logging needed.
            throw new StreamCorruptedException("Unknown callType: " + callType);
    }

    return objectValue;
}
 
Example 4
Source File: IIOPInputStream.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Factored out of inputClassFields and reused in
 * inputCurrentClassFieldsForReadFields.
 *
 * Reads the field (which of an Object type as opposed to a primitive)
 * described by ObjectStreamField field and returns it.
 */
private Object inputObjectField(ObjectStreamField field)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IndirectionException, IOException {

    if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
        return javax.rmi.CORBA.Util.readAny(orbStream);
    }

    Object objectValue = null;

    // fields have an API to provide the actual class
    // corresponding to the data type
    // Class type = osc.forClass();
    Class fieldType = field.getType();
    Class actualType = fieldType; // This may change if stub loaded.

    // Decide what method call to make based on the fieldType. If
    // it is a type for which we need to load a stub, convert
    // the type to the correct stub type.

    int callType = ValueHandlerImpl.kValueType;
    boolean narrow = false;

    if (fieldType.isInterface()) {
        boolean loadStubClass = false;

        if (java.rmi.Remote.class.isAssignableFrom(fieldType)) {

            // RMI Object reference...
            callType = ValueHandlerImpl.kRemoteType;

        } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){

            // IDL Object reference...
            callType = ValueHandlerImpl.kRemoteType;
            loadStubClass = true;

        } else if (vhandler.isAbstractBase(fieldType)) {
            // IDL Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
            loadStubClass = true;
        } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) {
            // RMI Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
        }

        if (loadStubClass) {
            try {
                String codebase = Util.getCodebase(fieldType);
                String repID = vhandler.createForAnyType(fieldType);
                Class stubType =
                    Utility.loadStubClass(repID, codebase, fieldType);
                actualType = stubType;
            } catch (ClassNotFoundException e) {
                narrow = true;
            }
        } else {
            narrow = true;
        }
    }

    switch (callType) {
        case ValueHandlerImpl.kRemoteType:
            if (!narrow)
                objectValue = (Object)orbStream.read_Object(actualType);
            else
                objectValue = Utility.readObjectAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kAbstractType:
            if (!narrow)
                objectValue = (Object)orbStream.read_abstract_interface(actualType);
            else
                objectValue = Utility.readAbstractAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kValueType:
            objectValue = (Object)orbStream.read_value(actualType);
            break;
        default:
            // XXX I18N, logging needed.
            throw new StreamCorruptedException("Unknown callType: " + callType);
    }

    return objectValue;
}
 
Example 5
Source File: IIOPInputStream.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Factored out of inputClassFields and reused in
 * inputCurrentClassFieldsForReadFields.
 *
 * Reads the field (which of an Object type as opposed to a primitive)
 * described by ObjectStreamField field and returns it.
 */
private Object inputObjectField(ObjectStreamField field)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IndirectionException, IOException {

    if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
        return javax.rmi.CORBA.Util.readAny(orbStream);
    }

    Object objectValue = null;

    // fields have an API to provide the actual class
    // corresponding to the data type
    // Class type = osc.forClass();
    Class fieldType = field.getType();
    Class actualType = fieldType; // This may change if stub loaded.

    // Decide what method call to make based on the fieldType. If
    // it is a type for which we need to load a stub, convert
    // the type to the correct stub type.

    int callType = ValueHandlerImpl.kValueType;
    boolean narrow = false;

    if (fieldType.isInterface()) {
        boolean loadStubClass = false;

        if (java.rmi.Remote.class.isAssignableFrom(fieldType)) {

            // RMI Object reference...
            callType = ValueHandlerImpl.kRemoteType;

        } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){

            // IDL Object reference...
            callType = ValueHandlerImpl.kRemoteType;
            loadStubClass = true;

        } else if (vhandler.isAbstractBase(fieldType)) {
            // IDL Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
            loadStubClass = true;
        } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) {
            // RMI Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
        }

        if (loadStubClass) {
            try {
                String codebase = Util.getCodebase(fieldType);
                String repID = vhandler.createForAnyType(fieldType);
                Class stubType =
                    Utility.loadStubClass(repID, codebase, fieldType);
                actualType = stubType;
            } catch (ClassNotFoundException e) {
                narrow = true;
            }
        } else {
            narrow = true;
        }
    }

    switch (callType) {
        case ValueHandlerImpl.kRemoteType:
            if (!narrow)
                objectValue = (Object)orbStream.read_Object(actualType);
            else
                objectValue = Utility.readObjectAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kAbstractType:
            if (!narrow)
                objectValue = (Object)orbStream.read_abstract_interface(actualType);
            else
                objectValue = Utility.readAbstractAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kValueType:
            objectValue = (Object)orbStream.read_value(actualType);
            break;
        default:
            // XXX I18N, logging needed.
            throw new StreamCorruptedException("Unknown callType: " + callType);
    }

    return objectValue;
}
 
Example 6
Source File: IIOPInputStream.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Factored out of inputClassFields and reused in
 * inputCurrentClassFieldsForReadFields.
 *
 * Reads the field (which of an Object type as opposed to a primitive)
 * described by ObjectStreamField field and returns it.
 */
private Object inputObjectField(ObjectStreamField field)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IndirectionException, IOException {

    if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
        return javax.rmi.CORBA.Util.readAny(orbStream);
    }

    Object objectValue = null;

    // fields have an API to provide the actual class
    // corresponding to the data type
    // Class type = osc.forClass();
    Class fieldType = field.getType();
    Class actualType = fieldType; // This may change if stub loaded.

    // Decide what method call to make based on the fieldType. If
    // it is a type for which we need to load a stub, convert
    // the type to the correct stub type.

    int callType = ValueHandlerImpl.kValueType;
    boolean narrow = false;

    if (fieldType.isInterface()) {
        boolean loadStubClass = false;

        if (java.rmi.Remote.class.isAssignableFrom(fieldType)) {

            // RMI Object reference...
            callType = ValueHandlerImpl.kRemoteType;

        } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){

            // IDL Object reference...
            callType = ValueHandlerImpl.kRemoteType;
            loadStubClass = true;

        } else if (vhandler.isAbstractBase(fieldType)) {
            // IDL Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
            loadStubClass = true;
        } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) {
            // RMI Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
        }

        if (loadStubClass) {
            try {
                String codebase = Util.getCodebase(fieldType);
                String repID = vhandler.createForAnyType(fieldType);
                Class stubType =
                    Utility.loadStubClass(repID, codebase, fieldType);
                actualType = stubType;
            } catch (ClassNotFoundException e) {
                narrow = true;
            }
        } else {
            narrow = true;
        }
    }

    switch (callType) {
        case ValueHandlerImpl.kRemoteType:
            if (!narrow)
                objectValue = (Object)orbStream.read_Object(actualType);
            else
                objectValue = Utility.readObjectAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kAbstractType:
            if (!narrow)
                objectValue = (Object)orbStream.read_abstract_interface(actualType);
            else
                objectValue = Utility.readAbstractAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kValueType:
            objectValue = (Object)orbStream.read_value(actualType);
            break;
        default:
            // XXX I18N, logging needed.
            throw new StreamCorruptedException("Unknown callType: " + callType);
    }

    return objectValue;
}
 
Example 7
Source File: IIOPInputStream.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Factored out of inputClassFields and reused in
 * inputCurrentClassFieldsForReadFields.
 *
 * Reads the field (which of an Object type as opposed to a primitive)
 * described by ObjectStreamField field and returns it.
 */
private Object inputObjectField(ObjectStreamField field)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IndirectionException, IOException {

    if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
        return javax.rmi.CORBA.Util.readAny(orbStream);
    }

    Object objectValue = null;

    // fields have an API to provide the actual class
    // corresponding to the data type
    // Class type = osc.forClass();
    Class fieldType = field.getType();
    Class actualType = fieldType; // This may change if stub loaded.

    // Decide what method call to make based on the fieldType. If
    // it is a type for which we need to load a stub, convert
    // the type to the correct stub type.

    int callType = ValueHandlerImpl.kValueType;
    boolean narrow = false;

    if (fieldType.isInterface()) {
        boolean loadStubClass = false;

        if (java.rmi.Remote.class.isAssignableFrom(fieldType)) {

            // RMI Object reference...
            callType = ValueHandlerImpl.kRemoteType;

        } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){

            // IDL Object reference...
            callType = ValueHandlerImpl.kRemoteType;
            loadStubClass = true;

        } else if (vhandler.isAbstractBase(fieldType)) {
            // IDL Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
            loadStubClass = true;
        } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) {
            // RMI Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
        }

        if (loadStubClass) {
            try {
                String codebase = Util.getCodebase(fieldType);
                String repID = vhandler.createForAnyType(fieldType);
                Class stubType =
                    Utility.loadStubClass(repID, codebase, fieldType);
                actualType = stubType;
            } catch (ClassNotFoundException e) {
                narrow = true;
            }
        } else {
            narrow = true;
        }
    }

    switch (callType) {
        case ValueHandlerImpl.kRemoteType:
            if (!narrow)
                objectValue = (Object)orbStream.read_Object(actualType);
            else
                objectValue = Utility.readObjectAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kAbstractType:
            if (!narrow)
                objectValue = (Object)orbStream.read_abstract_interface(actualType);
            else
                objectValue = Utility.readAbstractAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kValueType:
            objectValue = (Object)orbStream.read_value(actualType);
            break;
        default:
            // XXX I18N, logging needed.
            throw new StreamCorruptedException("Unknown callType: " + callType);
    }

    return objectValue;
}
 
Example 8
Source File: IIOPInputStream.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Factored out of inputClassFields and reused in
 * inputCurrentClassFieldsForReadFields.
 *
 * Reads the field (which of an Object type as opposed to a primitive)
 * described by ObjectStreamField field and returns it.
 */
private Object inputObjectField(ObjectStreamField field)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IndirectionException, IOException {

    if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
        return javax.rmi.CORBA.Util.readAny(orbStream);
    }

    Object objectValue = null;

    // fields have an API to provide the actual class
    // corresponding to the data type
    // Class type = osc.forClass();
    Class fieldType = field.getType();
    Class actualType = fieldType; // This may change if stub loaded.

    // Decide what method call to make based on the fieldType. If
    // it is a type for which we need to load a stub, convert
    // the type to the correct stub type.

    int callType = ValueHandlerImpl.kValueType;
    boolean narrow = false;

    if (fieldType.isInterface()) {
        boolean loadStubClass = false;

        if (java.rmi.Remote.class.isAssignableFrom(fieldType)) {

            // RMI Object reference...
            callType = ValueHandlerImpl.kRemoteType;

        } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){

            // IDL Object reference...
            callType = ValueHandlerImpl.kRemoteType;
            loadStubClass = true;

        } else if (vhandler.isAbstractBase(fieldType)) {
            // IDL Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
            loadStubClass = true;
        } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) {
            // RMI Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
        }

        if (loadStubClass) {
            try {
                String codebase = Util.getCodebase(fieldType);
                String repID = vhandler.createForAnyType(fieldType);
                Class stubType =
                    Utility.loadStubClass(repID, codebase, fieldType);
                actualType = stubType;
            } catch (ClassNotFoundException e) {
                narrow = true;
            }
        } else {
            narrow = true;
        }
    }

    switch (callType) {
        case ValueHandlerImpl.kRemoteType:
            if (!narrow)
                objectValue = (Object)orbStream.read_Object(actualType);
            else
                objectValue = Utility.readObjectAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kAbstractType:
            if (!narrow)
                objectValue = (Object)orbStream.read_abstract_interface(actualType);
            else
                objectValue = Utility.readAbstractAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kValueType:
            objectValue = (Object)orbStream.read_value(actualType);
            break;
        default:
            // XXX I18N, logging needed.
            throw new StreamCorruptedException("Unknown callType: " + callType);
    }

    return objectValue;
}
 
Example 9
Source File: IIOPInputStream.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Factored out of inputClassFields and reused in
 * inputCurrentClassFieldsForReadFields.
 *
 * Reads the field (which of an Object type as opposed to a primitive)
 * described by ObjectStreamField field and returns it.
 */
private Object inputObjectField(ObjectStreamField field)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IndirectionException, IOException {

    if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
        return javax.rmi.CORBA.Util.readAny(orbStream);
    }

    Object objectValue = null;

    // fields have an API to provide the actual class
    // corresponding to the data type
    // Class type = osc.forClass();
    Class fieldType = field.getType();
    Class actualType = fieldType; // This may change if stub loaded.

    // Decide what method call to make based on the fieldType. If
    // it is a type for which we need to load a stub, convert
    // the type to the correct stub type.

    int callType = ValueHandlerImpl.kValueType;
    boolean narrow = false;

    if (fieldType.isInterface()) {
        boolean loadStubClass = false;

        if (java.rmi.Remote.class.isAssignableFrom(fieldType)) {

            // RMI Object reference...
            callType = ValueHandlerImpl.kRemoteType;

        } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){

            // IDL Object reference...
            callType = ValueHandlerImpl.kRemoteType;
            loadStubClass = true;

        } else if (vhandler.isAbstractBase(fieldType)) {
            // IDL Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
            loadStubClass = true;
        } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) {
            // RMI Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
        }

        if (loadStubClass) {
            try {
                String codebase = Util.getCodebase(fieldType);
                String repID = vhandler.createForAnyType(fieldType);
                Class stubType =
                    Utility.loadStubClass(repID, codebase, fieldType);
                actualType = stubType;
            } catch (ClassNotFoundException e) {
                narrow = true;
            }
        } else {
            narrow = true;
        }
    }

    switch (callType) {
        case ValueHandlerImpl.kRemoteType:
            if (!narrow)
                objectValue = (Object)orbStream.read_Object(actualType);
            else
                objectValue = Utility.readObjectAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kAbstractType:
            if (!narrow)
                objectValue = (Object)orbStream.read_abstract_interface(actualType);
            else
                objectValue = Utility.readAbstractAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kValueType:
            objectValue = (Object)orbStream.read_value(actualType);
            break;
        default:
            // XXX I18N, logging needed.
            throw new StreamCorruptedException("Unknown callType: " + callType);
    }

    return objectValue;
}
 
Example 10
Source File: IIOPInputStream.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Factored out of inputClassFields and reused in
 * inputCurrentClassFieldsForReadFields.
 *
 * Reads the field (which of an Object type as opposed to a primitive)
 * described by ObjectStreamField field and returns it.
 */
private Object inputObjectField(ObjectStreamField field)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IndirectionException, IOException {

    if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
        return javax.rmi.CORBA.Util.readAny(orbStream);
    }

    Object objectValue = null;

    // fields have an API to provide the actual class
    // corresponding to the data type
    // Class type = osc.forClass();
    Class fieldType = field.getType();
    Class actualType = fieldType; // This may change if stub loaded.

    // Decide what method call to make based on the fieldType. If
    // it is a type for which we need to load a stub, convert
    // the type to the correct stub type.

    int callType = ValueHandlerImpl.kValueType;
    boolean narrow = false;

    if (fieldType.isInterface()) {
        boolean loadStubClass = false;

        if (java.rmi.Remote.class.isAssignableFrom(fieldType)) {

            // RMI Object reference...
            callType = ValueHandlerImpl.kRemoteType;

        } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){

            // IDL Object reference...
            callType = ValueHandlerImpl.kRemoteType;
            loadStubClass = true;

        } else if (vhandler.isAbstractBase(fieldType)) {
            // IDL Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
            loadStubClass = true;
        } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) {
            // RMI Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
        }

        if (loadStubClass) {
            try {
                String codebase = Util.getCodebase(fieldType);
                String repID = vhandler.createForAnyType(fieldType);
                Class stubType =
                    Utility.loadStubClass(repID, codebase, fieldType);
                actualType = stubType;
            } catch (ClassNotFoundException e) {
                narrow = true;
            }
        } else {
            narrow = true;
        }
    }

    switch (callType) {
        case ValueHandlerImpl.kRemoteType:
            if (!narrow)
                objectValue = (Object)orbStream.read_Object(actualType);
            else
                objectValue = Utility.readObjectAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kAbstractType:
            if (!narrow)
                objectValue = (Object)orbStream.read_abstract_interface(actualType);
            else
                objectValue = Utility.readAbstractAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kValueType:
            objectValue = (Object)orbStream.read_value(actualType);
            break;
        default:
            // XXX I18N, logging needed.
            throw new StreamCorruptedException("Unknown callType: " + callType);
    }

    return objectValue;
}