类org.omg.CORBA.portable.IndirectionException源码实例Demo

下面列出了怎么用org.omg.CORBA.portable.IndirectionException的API类实例代码及写法,或者点击链接到github查看源代码。

private Serializable handleIndirection() {
    int indirection = read_long() + get_offset() - 4;
    if (valueCache != null && valueCache.containsVal(indirection)) {

        java.io.Serializable cachedValue
            = (java.io.Serializable)valueCache.getKey(indirection);
        return cachedValue;
    } else {
        // In RMI-IIOP the ValueHandler will recognize this
        // exception and use the provided indirection value
        // to lookup a possible indirection to an object
        // currently on the deserialization stack.
        throw new IndirectionException(indirection);
    }
}
 
源代码2 项目: TencentKona-8   文件: CDRInputStream_1_0.java
private Serializable handleIndirection() {
    int indirection = read_long() + get_offset() - 4;
    if (valueCache != null && valueCache.containsVal(indirection)) {

        java.io.Serializable cachedValue
            = (java.io.Serializable)valueCache.getKey(indirection);
        return cachedValue;
    } else {
        // In RMI-IIOP the ValueHandler will recognize this
        // exception and use the provided indirection value
        // to lookup a possible indirection to an object
        // currently on the deserialization stack.
        throw new IndirectionException(indirection);
    }
}
 
源代码3 项目: jdk8u60   文件: CDRInputStream_1_0.java
private Serializable handleIndirection() {
    int indirection = read_long() + get_offset() - 4;
    if (valueCache != null && valueCache.containsVal(indirection)) {

        java.io.Serializable cachedValue
            = (java.io.Serializable)valueCache.getKey(indirection);
        return cachedValue;
    } else {
        // In RMI-IIOP the ValueHandler will recognize this
        // exception and use the provided indirection value
        // to lookup a possible indirection to an object
        // currently on the deserialization stack.
        throw new IndirectionException(indirection);
    }
}
 
源代码4 项目: JDKSourceCode1.8   文件: CDRInputStream_1_0.java
private Serializable handleIndirection() {
    int indirection = read_long() + get_offset() - 4;
    if (valueCache != null && valueCache.containsVal(indirection)) {

        java.io.Serializable cachedValue
            = (java.io.Serializable)valueCache.getKey(indirection);
        return cachedValue;
    } else {
        // In RMI-IIOP the ValueHandler will recognize this
        // exception and use the provided indirection value
        // to lookup a possible indirection to an object
        // currently on the deserialization stack.
        throw new IndirectionException(indirection);
    }
}
 
源代码5 项目: openjdk-jdk8u   文件: CDRInputStream_1_0.java
private Serializable handleIndirection() {
    int indirection = read_long() + get_offset() - 4;
    if (valueCache != null && valueCache.containsVal(indirection)) {

        java.io.Serializable cachedValue
            = (java.io.Serializable)valueCache.getKey(indirection);
        return cachedValue;
    } else {
        // In RMI-IIOP the ValueHandler will recognize this
        // exception and use the provided indirection value
        // to lookup a possible indirection to an object
        // currently on the deserialization stack.
        throw new IndirectionException(indirection);
    }
}
 
源代码6 项目: openjdk-jdk8u-backup   文件: CDRInputStream_1_0.java
private Serializable handleIndirection() {
    int indirection = read_long() + get_offset() - 4;
    if (valueCache != null && valueCache.containsVal(indirection)) {

        java.io.Serializable cachedValue
            = (java.io.Serializable)valueCache.getKey(indirection);
        return cachedValue;
    } else {
        // In RMI-IIOP the ValueHandler will recognize this
        // exception and use the provided indirection value
        // to lookup a possible indirection to an object
        // currently on the deserialization stack.
        throw new IndirectionException(indirection);
    }
}
 
源代码7 项目: openjdk-jdk9   文件: CDRInputStream_1_0.java
private Serializable handleIndirection() {
    int indirection = read_long() + get_offset() - 4;
    if (valueCache != null && valueCache.containsVal(indirection)) {

        java.io.Serializable cachedValue
            = (java.io.Serializable)valueCache.getKey(indirection);
        return cachedValue;
    } else {
        // In RMI-IIOP the ValueHandler will recognize this
        // exception and use the provided indirection value
        // to lookup a possible indirection to an object
        // currently on the deserialization stack.
        throw new IndirectionException(indirection);
    }
}
 
源代码8 项目: hottub   文件: CDRInputStream_1_0.java
private Serializable handleIndirection() {
    int indirection = read_long() + get_offset() - 4;
    if (valueCache != null && valueCache.containsVal(indirection)) {

        java.io.Serializable cachedValue
            = (java.io.Serializable)valueCache.getKey(indirection);
        return cachedValue;
    } else {
        // In RMI-IIOP the ValueHandler will recognize this
        // exception and use the provided indirection value
        // to lookup a possible indirection to an object
        // currently on the deserialization stack.
        throw new IndirectionException(indirection);
    }
}
 
源代码9 项目: openjdk-8-source   文件: CDRInputStream_1_0.java
private Serializable handleIndirection() {
    int indirection = read_long() + get_offset() - 4;
    if (valueCache != null && valueCache.containsVal(indirection)) {

        java.io.Serializable cachedValue
            = (java.io.Serializable)valueCache.getKey(indirection);
        return cachedValue;
    } else {
        // In RMI-IIOP the ValueHandler will recognize this
        // exception and use the provided indirection value
        // to lookup a possible indirection to an object
        // currently on the deserialization stack.
        throw new IndirectionException(indirection);
    }
}
 
源代码10 项目: openjdk-8   文件: CDRInputStream_1_0.java
private Serializable handleIndirection() {
    int indirection = read_long() + get_offset() - 4;
    if (valueCache != null && valueCache.containsVal(indirection)) {

        java.io.Serializable cachedValue
            = (java.io.Serializable)valueCache.getKey(indirection);
        return cachedValue;
    } else {
        // In RMI-IIOP the ValueHandler will recognize this
        // exception and use the provided indirection value
        // to lookup a possible indirection to an object
        // currently on the deserialization stack.
        throw new IndirectionException(indirection);
    }
}
 
源代码11 项目: jdk1.8-source-analysis   文件: IIOPInputStream.java
/**
 * Override the actions of the final method "readObject()"
 * in ObjectInputStream.
 * @since     JDK1.1.6
 *
 * Read an object from the ObjectInputStream.
 * The class of the object, the signature of the class, and the values
 * of the non-transient and non-static fields of the class and all
 * of its supertypes are read.  Default deserializing for a class can be
 * overriden using the writeObject and readObject methods.
 * Objects referenced by this object are read transitively so
 * that a complete equivalent graph of objects is reconstructed by readObject. <p>
 *
 * The root object is completly restored when all of its fields
 * and the objects it references are completely restored.  At this
 * point the object validation callbacks are executed in order
 * based on their registered priorities. The callbacks are
 * registered by objects (in the readObject special methods)
 * as they are individually restored.
 *
 * Exceptions are thrown for problems with the InputStream and for classes
 * that should not be deserialized.  All exceptions are fatal to the
 * InputStream and leave it in an indeterminate state; it is up to the caller
 * to ignore or recover the stream state.
 * @exception java.lang.ClassNotFoundException Class of a serialized object
 *      cannot be found.
 * @exception InvalidClassException Something is wrong with a class used by
 *     serialization.
 * @exception StreamCorruptedException Control information in the
 *     stream is inconsistent.
 * @exception OptionalDataException Primitive data was found in the
 * stream instead of objects.
 * @exception IOException Any of the usual Input/Output related exceptions.
 * @since     JDK1.1
 */
public final synchronized Object readObjectDelegate() throws IOException
{
    try {

        readObjectState.readData(this);

        return orbStream.read_abstract_interface();
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, true);
        throw marshalException;
    } catch(IndirectionException cdrie)
        {
            // The CDR stream had never seen the given offset before,
            // so check the recursion manager (it will throw an
            // IOException if it doesn't have a reference, either).
            return activeRecursionMgr.getObject(cdrie.offset);
        }
}
 
源代码12 项目: jdk1.8-source-analysis   文件: IIOPInputStream.java
private Object inputObjectField(org.omg.CORBA.ValueMember field,
                                com.sun.org.omg.SendingContext.CodeBase sender)
    throws IndirectionException, ClassNotFoundException, IOException,
           StreamCorruptedException {

    Object objectValue = null;
    Class type = null;
    String id = field.id;

    try {
        type = vhandler.getClassFromType(id);
    } catch(ClassNotFoundException cnfe) {
        // Make sure type = null
        type = null;
    }

    String signature = null;
    if (type != null)
        signature = ValueUtility.getSignature(field);

    if (signature != null && (signature.equals("Ljava/lang/Object;") ||
                              signature.equals("Ljava/io/Serializable;") ||
                              signature.equals("Ljava/io/Externalizable;"))) {
        objectValue = javax.rmi.CORBA.Util.readAny(orbStream);
    } else {
        // Decide what method call to make based on the type. If
        // it is a type for which we need to load a stub, convert
        // the type to the correct stub type.
        //
        // NOTE : Since FullValueDescription does not allow us
        // to ask whether something is an interface we do not
        // have the ability to optimize this check.

        int callType = ValueHandlerImpl.kValueType;

        if (!vhandler.isSequence(id)) {

            if (field.type.kind().value() == kRemoteTypeCode.kind().value()) {

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

            } else {

                // REVISIT.  If we don't have the local class,
                // we should probably verify that it's an RMI type,
                // query the remote FVD, and use is_abstract.
                // Our FVD seems to get NullPointerExceptions for any
                // non-RMI types.

                // This uses the local class in the same way as
                // inputObjectField(ObjectStreamField) does.  REVISIT
                // inputObjectField(ObjectStreamField)'s loadStubClass
                // logic.  Assumption is that the given type cannot
                // evolve to become a CORBA abstract interface or
                // a RMI abstract interface.

                if (type != null && type.isInterface() &&
                    (vhandler.isAbstractBase(type) ||
                     ObjectStreamClassCorbaExt.isAbstractInterface(type))) {

                    callType = ValueHandlerImpl.kAbstractType;
                }
            }
        }

        // Now that we have used the FVD of the field to determine the proper course
        // of action, it is ok to use the type (Class) from this point forward since
        // the rep. id for this read will also follow on the wire.

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

    return objectValue;
}
 
源代码13 项目: jdk1.8-source-analysis   文件: IIOPInputStream.java
/**
 * 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;
}
 
源代码14 项目: jdk1.8-source-analysis   文件: IIOPInputStream.java
private final void inputRemoteMembersForReadFields(java.util.Map fieldToValueMap)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IOException {

    // Must have this local variable since defaultReadObjectFVDMembers
    // may get mangled by recursion.
    ValueMember fields[] = defaultReadObjectFVDMembers;

    try {

        for (int i = 0; i < fields.length; i++) {

            switch (fields[i].type.kind().value()) {

            case TCKind._tk_octet:
                byte byteValue = orbStream.read_octet();
                fieldToValueMap.put(fields[i].name, new Byte(byteValue));
                break;
            case TCKind._tk_boolean:
                boolean booleanValue = orbStream.read_boolean();
                fieldToValueMap.put(fields[i].name, new Boolean(booleanValue));
                break;
            case TCKind._tk_char:
                // Backwards compatibility.  Older Sun ORBs sent
                // _tk_char even though they read and wrote wchars
                // correctly.
                //
                // Fall through to the _tk_wchar case.
            case TCKind._tk_wchar:
                char charValue = orbStream.read_wchar();
                fieldToValueMap.put(fields[i].name, new Character(charValue));
                break;
            case TCKind._tk_short:
                short shortValue = orbStream.read_short();
                fieldToValueMap.put(fields[i].name, new Short(shortValue));
                break;
            case TCKind._tk_long:
                int intValue = orbStream.read_long();
                fieldToValueMap.put(fields[i].name, new Integer(intValue));
                break;
            case TCKind._tk_longlong:
                long longValue = orbStream.read_longlong();
                fieldToValueMap.put(fields[i].name, new Long(longValue));
                break;
            case TCKind._tk_float:
                float floatValue = orbStream.read_float();
                fieldToValueMap.put(fields[i].name, new Float(floatValue));
                break;
            case TCKind._tk_double:
                double doubleValue = orbStream.read_double();
                fieldToValueMap.put(fields[i].name, new Double(doubleValue));
                break;
            case TCKind._tk_value:
            case TCKind._tk_objref:
            case TCKind._tk_value_box:
                Object objectValue = null;
                try {
                    objectValue = inputObjectField(fields[i],
                                                   cbSender);

                } catch (IndirectionException cdrie) {
                    // The CDR stream had never seen the given offset before,
                    // so check the recursion manager (it will throw an
                    // IOException if it doesn't have a reference, either).
                    objectValue = activeRecursionMgr.getObject(cdrie.offset);
                }

                fieldToValueMap.put(fields[i].name, objectValue);
                break;
            default:
                // XXX I18N, logging needed.
                throw new StreamCorruptedException("Unknown kind: "
                                                   + fields[i].type.kind().value());
            }
        }
    } catch (Throwable t) {
        StreamCorruptedException result = new StreamCorruptedException(t.getMessage());
        result.initCause(t);
        throw result;
    }
}
 
源代码15 项目: jdk1.8-source-analysis   文件: IIOPInputStream.java
/**
 * Called from InputStreamHook.
 *
 * Reads the fields of the current class (could be the ones
 * queried from the remote FVD) and puts them in
 * the given Map, name to value.  Wraps primitives in the
 * corresponding java.lang Objects.
 */
private final void inputCurrentClassFieldsForReadFields(java.util.Map fieldToValueMap)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IOException {

    ObjectStreamField[] fields = currentClassDesc.getFieldsNoCopy();

    int primFields = fields.length - currentClassDesc.objFields;

    // Handle the primitives first
    for (int i = 0; i < primFields; ++i) {

        switch (fields[i].getTypeCode()) {
            case 'B':
                byte byteValue = orbStream.read_octet();
                fieldToValueMap.put(fields[i].getName(),
                                    new Byte(byteValue));
                break;
            case 'Z':
               boolean booleanValue = orbStream.read_boolean();
               fieldToValueMap.put(fields[i].getName(),
                                   new Boolean(booleanValue));
               break;
            case 'C':
                char charValue = orbStream.read_wchar();
                fieldToValueMap.put(fields[i].getName(),
                                    new Character(charValue));
                break;
            case 'S':
                short shortValue = orbStream.read_short();
                fieldToValueMap.put(fields[i].getName(),
                                    new Short(shortValue));
                break;
            case 'I':
                int intValue = orbStream.read_long();
                fieldToValueMap.put(fields[i].getName(),
                                    new Integer(intValue));
                break;
            case 'J':
                long longValue = orbStream.read_longlong();
                fieldToValueMap.put(fields[i].getName(),
                                    new Long(longValue));
                break;
            case 'F' :
                float floatValue = orbStream.read_float();
                fieldToValueMap.put(fields[i].getName(),
                                    new Float(floatValue));
                break;
            case 'D' :
                double doubleValue = orbStream.read_double();
                fieldToValueMap.put(fields[i].getName(),
                                    new Double(doubleValue));
                break;
            default:
                // XXX I18N, logging needed.
                throw new InvalidClassException(currentClassDesc.getName());
        }
    }

    /* Read and set object fields from the input stream. */
    if (currentClassDesc.objFields > 0) {
        for (int i = primFields; i < fields.length; i++) {
            Object objectValue = null;
            try {
                objectValue = inputObjectField(fields[i]);
            } catch(IndirectionException cdrie) {
                // The CDR stream had never seen the given offset before,
                // so check the recursion manager (it will throw an
                // IOException if it doesn't have a reference, either).
                objectValue = activeRecursionMgr.getObject(cdrie.offset);
            }

            fieldToValueMap.put(fields[i].getName(), objectValue);
        }
    }
}
 
源代码16 项目: jdk1.8-source-analysis   文件: IIOPInputStream.java
private void inputClassFields(Object o, final Class<?> cl,
                              ObjectStreamField[] fields,
                              com.sun.org.omg.SendingContext.CodeBase sender)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IOException
{

    int primFields = fields.length - currentClassDesc.objFields;

    if (o != null) {
        for (int i = 0; i < primFields; ++i) {
            inputPrimitiveField(o, cl, fields[i]);
        }
    }

    /* Read and set object fields from the input stream. */
    if (currentClassDesc.objFields > 0) {
        for (int i = primFields; i < fields.length; i++) {
            Object objectValue = null;

            try {
                objectValue = inputObjectField(fields[i]);
            } catch(IndirectionException cdrie) {
                // The CDR stream had never seen the given offset before,
                // so check the recursion manager (it will throw an
                // IOException if it doesn't have a reference, either).
                objectValue = activeRecursionMgr.getObject(cdrie.offset);
            }

            if ((o == null) || (fields[i].getField() == null)) {
                continue;
            }

            try {
                Class<?> fieldCl = fields[i].getClazz();
                if ((objectValue != null)
                        && (!fieldCl.isAssignableFrom(
                                objectValue.getClass()))) {
                    throw new IllegalArgumentException("Field mismatch");
                }
                Field declaredClassField = null;
                final String inputStreamFieldName = fields[i].getName();
                try {
                    declaredClassField = getDeclaredField( cl, inputStreamFieldName);
                } catch (PrivilegedActionException paEx) {
                    throw new IllegalArgumentException(
                        (NoSuchFieldException) paEx.getException());
                } catch (SecurityException secEx) {
                    throw new IllegalArgumentException(secEx);
                }  catch (NullPointerException npEx) {
                    continue;
                } catch (NoSuchFieldException e) {
                    continue;
                }

                if (declaredClassField == null) {
                    continue;
                }
                Class<?> declaredFieldClass = declaredClassField.getType();

                // check input field type is a declared field type
                // input field is a subclass of the declared field
                if (!declaredFieldClass.isAssignableFrom(fieldCl)) {
                    throw new IllegalArgumentException(
                            "Field Type mismatch");
                }
                if (objectValue != null && !fieldCl.isInstance(objectValue)) {
                    throw new IllegalArgumentException();
                }
                bridge.putObject( o, fields[i].getFieldID(), objectValue ) ;
                // reflective code: fields[i].getField().set( o, objectValue ) ;
            } catch (IllegalArgumentException iaEx) {
                String objectValueClassName = "null";
                String currentClassDescClassName = "null";
                String fieldName = "null";
                if (objectValue != null) {
                    objectValueClassName = objectValue.getClass().getName();
                }
                if (currentClassDesc != null) {
                    currentClassDescClassName = currentClassDesc.getName();
                }
                if (fields[i] != null && fields[i].getField() != null) {
                    fieldName = fields[i].getField().getName();
                }
                ClassCastException ccEx = new ClassCastException(
                        "Assigning instance of class " + objectValueClassName
                                + " to field " + currentClassDescClassName + '#' + fieldName);
                ccEx.initCause( iaEx ) ;
                throw ccEx ;
            }
        } // end : for loop
        }
    }
 
源代码17 项目: TencentKona-8   文件: IIOPInputStream.java
/**
 * Override the actions of the final method "readObject()"
 * in ObjectInputStream.
 * @since     JDK1.1.6
 *
 * Read an object from the ObjectInputStream.
 * The class of the object, the signature of the class, and the values
 * of the non-transient and non-static fields of the class and all
 * of its supertypes are read.  Default deserializing for a class can be
 * overriden using the writeObject and readObject methods.
 * Objects referenced by this object are read transitively so
 * that a complete equivalent graph of objects is reconstructed by readObject. <p>
 *
 * The root object is completly restored when all of its fields
 * and the objects it references are completely restored.  At this
 * point the object validation callbacks are executed in order
 * based on their registered priorities. The callbacks are
 * registered by objects (in the readObject special methods)
 * as they are individually restored.
 *
 * Exceptions are thrown for problems with the InputStream and for classes
 * that should not be deserialized.  All exceptions are fatal to the
 * InputStream and leave it in an indeterminate state; it is up to the caller
 * to ignore or recover the stream state.
 * @exception java.lang.ClassNotFoundException Class of a serialized object
 *      cannot be found.
 * @exception InvalidClassException Something is wrong with a class used by
 *     serialization.
 * @exception StreamCorruptedException Control information in the
 *     stream is inconsistent.
 * @exception OptionalDataException Primitive data was found in the
 * stream instead of objects.
 * @exception IOException Any of the usual Input/Output related exceptions.
 * @since     JDK1.1
 */
public final synchronized Object readObjectDelegate() throws IOException
{
    try {

        readObjectState.readData(this);

        return orbStream.read_abstract_interface();
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, true);
        throw marshalException;
    } catch(IndirectionException cdrie)
        {
            // The CDR stream had never seen the given offset before,
            // so check the recursion manager (it will throw an
            // IOException if it doesn't have a reference, either).
            return activeRecursionMgr.getObject(cdrie.offset);
        }
}
 
源代码18 项目: TencentKona-8   文件: IIOPInputStream.java
private Object inputObjectField(org.omg.CORBA.ValueMember field,
                                com.sun.org.omg.SendingContext.CodeBase sender)
    throws IndirectionException, ClassNotFoundException, IOException,
           StreamCorruptedException {

    Object objectValue = null;
    Class type = null;
    String id = field.id;

    try {
        type = vhandler.getClassFromType(id);
    } catch(ClassNotFoundException cnfe) {
        // Make sure type = null
        type = null;
    }

    String signature = null;
    if (type != null)
        signature = ValueUtility.getSignature(field);

    if (signature != null && (signature.equals("Ljava/lang/Object;") ||
                              signature.equals("Ljava/io/Serializable;") ||
                              signature.equals("Ljava/io/Externalizable;"))) {
        objectValue = javax.rmi.CORBA.Util.readAny(orbStream);
    } else {
        // Decide what method call to make based on the type. If
        // it is a type for which we need to load a stub, convert
        // the type to the correct stub type.
        //
        // NOTE : Since FullValueDescription does not allow us
        // to ask whether something is an interface we do not
        // have the ability to optimize this check.

        int callType = ValueHandlerImpl.kValueType;

        if (!vhandler.isSequence(id)) {

            if (field.type.kind().value() == kRemoteTypeCode.kind().value()) {

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

            } else {

                // REVISIT.  If we don't have the local class,
                // we should probably verify that it's an RMI type,
                // query the remote FVD, and use is_abstract.
                // Our FVD seems to get NullPointerExceptions for any
                // non-RMI types.

                // This uses the local class in the same way as
                // inputObjectField(ObjectStreamField) does.  REVISIT
                // inputObjectField(ObjectStreamField)'s loadStubClass
                // logic.  Assumption is that the given type cannot
                // evolve to become a CORBA abstract interface or
                // a RMI abstract interface.

                if (type != null && type.isInterface() &&
                    (vhandler.isAbstractBase(type) ||
                     ObjectStreamClassCorbaExt.isAbstractInterface(type))) {

                    callType = ValueHandlerImpl.kAbstractType;
                }
            }
        }

        // Now that we have used the FVD of the field to determine the proper course
        // of action, it is ok to use the type (Class) from this point forward since
        // the rep. id for this read will also follow on the wire.

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

    return objectValue;
}
 
源代码19 项目: TencentKona-8   文件: IIOPInputStream.java
/**
 * 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;
}
 
源代码20 项目: TencentKona-8   文件: IIOPInputStream.java
private final void inputRemoteMembersForReadFields(java.util.Map fieldToValueMap)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IOException {

    // Must have this local variable since defaultReadObjectFVDMembers
    // may get mangled by recursion.
    ValueMember fields[] = defaultReadObjectFVDMembers;

    try {

        for (int i = 0; i < fields.length; i++) {

            switch (fields[i].type.kind().value()) {

            case TCKind._tk_octet:
                byte byteValue = orbStream.read_octet();
                fieldToValueMap.put(fields[i].name, new Byte(byteValue));
                break;
            case TCKind._tk_boolean:
                boolean booleanValue = orbStream.read_boolean();
                fieldToValueMap.put(fields[i].name, new Boolean(booleanValue));
                break;
            case TCKind._tk_char:
                // Backwards compatibility.  Older Sun ORBs sent
                // _tk_char even though they read and wrote wchars
                // correctly.
                //
                // Fall through to the _tk_wchar case.
            case TCKind._tk_wchar:
                char charValue = orbStream.read_wchar();
                fieldToValueMap.put(fields[i].name, new Character(charValue));
                break;
            case TCKind._tk_short:
                short shortValue = orbStream.read_short();
                fieldToValueMap.put(fields[i].name, new Short(shortValue));
                break;
            case TCKind._tk_long:
                int intValue = orbStream.read_long();
                fieldToValueMap.put(fields[i].name, new Integer(intValue));
                break;
            case TCKind._tk_longlong:
                long longValue = orbStream.read_longlong();
                fieldToValueMap.put(fields[i].name, new Long(longValue));
                break;
            case TCKind._tk_float:
                float floatValue = orbStream.read_float();
                fieldToValueMap.put(fields[i].name, new Float(floatValue));
                break;
            case TCKind._tk_double:
                double doubleValue = orbStream.read_double();
                fieldToValueMap.put(fields[i].name, new Double(doubleValue));
                break;
            case TCKind._tk_value:
            case TCKind._tk_objref:
            case TCKind._tk_value_box:
                Object objectValue = null;
                try {
                    objectValue = inputObjectField(fields[i],
                                                   cbSender);

                } catch (IndirectionException cdrie) {
                    // The CDR stream had never seen the given offset before,
                    // so check the recursion manager (it will throw an
                    // IOException if it doesn't have a reference, either).
                    objectValue = activeRecursionMgr.getObject(cdrie.offset);
                }

                fieldToValueMap.put(fields[i].name, objectValue);
                break;
            default:
                // XXX I18N, logging needed.
                throw new StreamCorruptedException("Unknown kind: "
                                                   + fields[i].type.kind().value());
            }
        }
    } catch (Throwable t) {
        StreamCorruptedException result = new StreamCorruptedException(t.getMessage());
        result.initCause(t);
        throw result;
    }
}
 
源代码21 项目: TencentKona-8   文件: IIOPInputStream.java
/**
 * Called from InputStreamHook.
 *
 * Reads the fields of the current class (could be the ones
 * queried from the remote FVD) and puts them in
 * the given Map, name to value.  Wraps primitives in the
 * corresponding java.lang Objects.
 */
private final void inputCurrentClassFieldsForReadFields(java.util.Map fieldToValueMap)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IOException {

    ObjectStreamField[] fields = currentClassDesc.getFieldsNoCopy();

    int primFields = fields.length - currentClassDesc.objFields;

    // Handle the primitives first
    for (int i = 0; i < primFields; ++i) {

        switch (fields[i].getTypeCode()) {
            case 'B':
                byte byteValue = orbStream.read_octet();
                fieldToValueMap.put(fields[i].getName(),
                                    new Byte(byteValue));
                break;
            case 'Z':
               boolean booleanValue = orbStream.read_boolean();
               fieldToValueMap.put(fields[i].getName(),
                                   new Boolean(booleanValue));
               break;
            case 'C':
                char charValue = orbStream.read_wchar();
                fieldToValueMap.put(fields[i].getName(),
                                    new Character(charValue));
                break;
            case 'S':
                short shortValue = orbStream.read_short();
                fieldToValueMap.put(fields[i].getName(),
                                    new Short(shortValue));
                break;
            case 'I':
                int intValue = orbStream.read_long();
                fieldToValueMap.put(fields[i].getName(),
                                    new Integer(intValue));
                break;
            case 'J':
                long longValue = orbStream.read_longlong();
                fieldToValueMap.put(fields[i].getName(),
                                    new Long(longValue));
                break;
            case 'F' :
                float floatValue = orbStream.read_float();
                fieldToValueMap.put(fields[i].getName(),
                                    new Float(floatValue));
                break;
            case 'D' :
                double doubleValue = orbStream.read_double();
                fieldToValueMap.put(fields[i].getName(),
                                    new Double(doubleValue));
                break;
            default:
                // XXX I18N, logging needed.
                throw new InvalidClassException(currentClassDesc.getName());
        }
    }

    /* Read and set object fields from the input stream. */
    if (currentClassDesc.objFields > 0) {
        for (int i = primFields; i < fields.length; i++) {
            Object objectValue = null;
            try {
                objectValue = inputObjectField(fields[i]);
            } catch(IndirectionException cdrie) {
                // The CDR stream had never seen the given offset before,
                // so check the recursion manager (it will throw an
                // IOException if it doesn't have a reference, either).
                objectValue = activeRecursionMgr.getObject(cdrie.offset);
            }

            fieldToValueMap.put(fields[i].getName(), objectValue);
        }
    }
}
 
源代码22 项目: TencentKona-8   文件: IIOPInputStream.java
private void inputClassFields(Object o, final Class<?> cl,
                              ObjectStreamField[] fields,
                              com.sun.org.omg.SendingContext.CodeBase sender)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IOException
{

    int primFields = fields.length - currentClassDesc.objFields;

    if (o != null) {
        for (int i = 0; i < primFields; ++i) {
            inputPrimitiveField(o, cl, fields[i]);
        }
    }

    /* Read and set object fields from the input stream. */
    if (currentClassDesc.objFields > 0) {
        for (int i = primFields; i < fields.length; i++) {
            Object objectValue = null;

            try {
                objectValue = inputObjectField(fields[i]);
            } catch(IndirectionException cdrie) {
                // The CDR stream had never seen the given offset before,
                // so check the recursion manager (it will throw an
                // IOException if it doesn't have a reference, either).
                objectValue = activeRecursionMgr.getObject(cdrie.offset);
            }

            if ((o == null) || (fields[i].getField() == null)) {
                continue;
            }

            try {
                Class<?> fieldCl = fields[i].getClazz();
                if ((objectValue != null)
                        && (!fieldCl.isAssignableFrom(
                                objectValue.getClass()))) {
                    throw new IllegalArgumentException("Field mismatch");
                }
                Field declaredClassField = null;
                final String inputStreamFieldName = fields[i].getName();
                try {
                    declaredClassField = getDeclaredField( cl, inputStreamFieldName);
                } catch (PrivilegedActionException paEx) {
                    throw new IllegalArgumentException(
                        (NoSuchFieldException) paEx.getException());
                } catch (SecurityException secEx) {
                    throw new IllegalArgumentException(secEx);
                }  catch (NullPointerException npEx) {
                    continue;
                } catch (NoSuchFieldException e) {
                    continue;
                }

                if (declaredClassField == null) {
                    continue;
                }
                Class<?> declaredFieldClass = declaredClassField.getType();

                // check input field type is a declared field type
                // input field is a subclass of the declared field
                if (!declaredFieldClass.isAssignableFrom(fieldCl)) {
                    throw new IllegalArgumentException(
                            "Field Type mismatch");
                }
                if (objectValue != null && !fieldCl.isInstance(objectValue)) {
                    throw new IllegalArgumentException();
                }
                bridge.putObject( o, fields[i].getFieldID(), objectValue ) ;
                // reflective code: fields[i].getField().set( o, objectValue ) ;
            } catch (IllegalArgumentException iaEx) {
                String objectValueClassName = "null";
                String currentClassDescClassName = "null";
                String fieldName = "null";
                if (objectValue != null) {
                    objectValueClassName = objectValue.getClass().getName();
                }
                if (currentClassDesc != null) {
                    currentClassDescClassName = currentClassDesc.getName();
                }
                if (fields[i] != null && fields[i].getField() != null) {
                    fieldName = fields[i].getField().getName();
                }
                ClassCastException ccEx = new ClassCastException(
                        "Assigning instance of class " + objectValueClassName
                                + " to field " + currentClassDescClassName + '#' + fieldName);
                ccEx.initCause( iaEx ) ;
                throw ccEx ;
            }
        } // end : for loop
        }
    }
 
源代码23 项目: jdk8u60   文件: IIOPInputStream.java
/**
 * Override the actions of the final method "readObject()"
 * in ObjectInputStream.
 * @since     JDK1.1.6
 *
 * Read an object from the ObjectInputStream.
 * The class of the object, the signature of the class, and the values
 * of the non-transient and non-static fields of the class and all
 * of its supertypes are read.  Default deserializing for a class can be
 * overriden using the writeObject and readObject methods.
 * Objects referenced by this object are read transitively so
 * that a complete equivalent graph of objects is reconstructed by readObject. <p>
 *
 * The root object is completly restored when all of its fields
 * and the objects it references are completely restored.  At this
 * point the object validation callbacks are executed in order
 * based on their registered priorities. The callbacks are
 * registered by objects (in the readObject special methods)
 * as they are individually restored.
 *
 * Exceptions are thrown for problems with the InputStream and for classes
 * that should not be deserialized.  All exceptions are fatal to the
 * InputStream and leave it in an indeterminate state; it is up to the caller
 * to ignore or recover the stream state.
 * @exception java.lang.ClassNotFoundException Class of a serialized object
 *      cannot be found.
 * @exception InvalidClassException Something is wrong with a class used by
 *     serialization.
 * @exception StreamCorruptedException Control information in the
 *     stream is inconsistent.
 * @exception OptionalDataException Primitive data was found in the
 * stream instead of objects.
 * @exception IOException Any of the usual Input/Output related exceptions.
 * @since     JDK1.1
 */
public final synchronized Object readObjectDelegate() throws IOException
{
    try {

        readObjectState.readData(this);

        return orbStream.read_abstract_interface();
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, true);
        throw marshalException;
    } catch(IndirectionException cdrie)
        {
            // The CDR stream had never seen the given offset before,
            // so check the recursion manager (it will throw an
            // IOException if it doesn't have a reference, either).
            return activeRecursionMgr.getObject(cdrie.offset);
        }
}
 
源代码24 项目: jdk8u60   文件: IIOPInputStream.java
private Object inputObjectField(org.omg.CORBA.ValueMember field,
                                com.sun.org.omg.SendingContext.CodeBase sender)
    throws IndirectionException, ClassNotFoundException, IOException,
           StreamCorruptedException {

    Object objectValue = null;
    Class type = null;
    String id = field.id;

    try {
        type = vhandler.getClassFromType(id);
    } catch(ClassNotFoundException cnfe) {
        // Make sure type = null
        type = null;
    }

    String signature = null;
    if (type != null)
        signature = ValueUtility.getSignature(field);

    if (signature != null && (signature.equals("Ljava/lang/Object;") ||
                              signature.equals("Ljava/io/Serializable;") ||
                              signature.equals("Ljava/io/Externalizable;"))) {
        objectValue = javax.rmi.CORBA.Util.readAny(orbStream);
    } else {
        // Decide what method call to make based on the type. If
        // it is a type for which we need to load a stub, convert
        // the type to the correct stub type.
        //
        // NOTE : Since FullValueDescription does not allow us
        // to ask whether something is an interface we do not
        // have the ability to optimize this check.

        int callType = ValueHandlerImpl.kValueType;

        if (!vhandler.isSequence(id)) {

            if (field.type.kind().value() == kRemoteTypeCode.kind().value()) {

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

            } else {

                // REVISIT.  If we don't have the local class,
                // we should probably verify that it's an RMI type,
                // query the remote FVD, and use is_abstract.
                // Our FVD seems to get NullPointerExceptions for any
                // non-RMI types.

                // This uses the local class in the same way as
                // inputObjectField(ObjectStreamField) does.  REVISIT
                // inputObjectField(ObjectStreamField)'s loadStubClass
                // logic.  Assumption is that the given type cannot
                // evolve to become a CORBA abstract interface or
                // a RMI abstract interface.

                if (type != null && type.isInterface() &&
                    (vhandler.isAbstractBase(type) ||
                     ObjectStreamClassCorbaExt.isAbstractInterface(type))) {

                    callType = ValueHandlerImpl.kAbstractType;
                }
            }
        }

        // Now that we have used the FVD of the field to determine the proper course
        // of action, it is ok to use the type (Class) from this point forward since
        // the rep. id for this read will also follow on the wire.

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

    return objectValue;
}
 
源代码25 项目: jdk8u60   文件: IIOPInputStream.java
/**
 * 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;
}
 
源代码26 项目: jdk8u60   文件: IIOPInputStream.java
private final void inputRemoteMembersForReadFields(java.util.Map fieldToValueMap)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IOException {

    // Must have this local variable since defaultReadObjectFVDMembers
    // may get mangled by recursion.
    ValueMember fields[] = defaultReadObjectFVDMembers;

    try {

        for (int i = 0; i < fields.length; i++) {

            switch (fields[i].type.kind().value()) {

            case TCKind._tk_octet:
                byte byteValue = orbStream.read_octet();
                fieldToValueMap.put(fields[i].name, new Byte(byteValue));
                break;
            case TCKind._tk_boolean:
                boolean booleanValue = orbStream.read_boolean();
                fieldToValueMap.put(fields[i].name, new Boolean(booleanValue));
                break;
            case TCKind._tk_char:
                // Backwards compatibility.  Older Sun ORBs sent
                // _tk_char even though they read and wrote wchars
                // correctly.
                //
                // Fall through to the _tk_wchar case.
            case TCKind._tk_wchar:
                char charValue = orbStream.read_wchar();
                fieldToValueMap.put(fields[i].name, new Character(charValue));
                break;
            case TCKind._tk_short:
                short shortValue = orbStream.read_short();
                fieldToValueMap.put(fields[i].name, new Short(shortValue));
                break;
            case TCKind._tk_long:
                int intValue = orbStream.read_long();
                fieldToValueMap.put(fields[i].name, new Integer(intValue));
                break;
            case TCKind._tk_longlong:
                long longValue = orbStream.read_longlong();
                fieldToValueMap.put(fields[i].name, new Long(longValue));
                break;
            case TCKind._tk_float:
                float floatValue = orbStream.read_float();
                fieldToValueMap.put(fields[i].name, new Float(floatValue));
                break;
            case TCKind._tk_double:
                double doubleValue = orbStream.read_double();
                fieldToValueMap.put(fields[i].name, new Double(doubleValue));
                break;
            case TCKind._tk_value:
            case TCKind._tk_objref:
            case TCKind._tk_value_box:
                Object objectValue = null;
                try {
                    objectValue = inputObjectField(fields[i],
                                                   cbSender);

                } catch (IndirectionException cdrie) {
                    // The CDR stream had never seen the given offset before,
                    // so check the recursion manager (it will throw an
                    // IOException if it doesn't have a reference, either).
                    objectValue = activeRecursionMgr.getObject(cdrie.offset);
                }

                fieldToValueMap.put(fields[i].name, objectValue);
                break;
            default:
                // XXX I18N, logging needed.
                throw new StreamCorruptedException("Unknown kind: "
                                                   + fields[i].type.kind().value());
            }
        }
    } catch (Throwable t) {
        StreamCorruptedException result = new StreamCorruptedException(t.getMessage());
        result.initCause(t);
        throw result;
    }
}
 
源代码27 项目: jdk8u60   文件: IIOPInputStream.java
/**
 * Called from InputStreamHook.
 *
 * Reads the fields of the current class (could be the ones
 * queried from the remote FVD) and puts them in
 * the given Map, name to value.  Wraps primitives in the
 * corresponding java.lang Objects.
 */
private final void inputCurrentClassFieldsForReadFields(java.util.Map fieldToValueMap)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IOException {

    ObjectStreamField[] fields = currentClassDesc.getFieldsNoCopy();

    int primFields = fields.length - currentClassDesc.objFields;

    // Handle the primitives first
    for (int i = 0; i < primFields; ++i) {

        switch (fields[i].getTypeCode()) {
            case 'B':
                byte byteValue = orbStream.read_octet();
                fieldToValueMap.put(fields[i].getName(),
                                    new Byte(byteValue));
                break;
            case 'Z':
               boolean booleanValue = orbStream.read_boolean();
               fieldToValueMap.put(fields[i].getName(),
                                   new Boolean(booleanValue));
               break;
            case 'C':
                char charValue = orbStream.read_wchar();
                fieldToValueMap.put(fields[i].getName(),
                                    new Character(charValue));
                break;
            case 'S':
                short shortValue = orbStream.read_short();
                fieldToValueMap.put(fields[i].getName(),
                                    new Short(shortValue));
                break;
            case 'I':
                int intValue = orbStream.read_long();
                fieldToValueMap.put(fields[i].getName(),
                                    new Integer(intValue));
                break;
            case 'J':
                long longValue = orbStream.read_longlong();
                fieldToValueMap.put(fields[i].getName(),
                                    new Long(longValue));
                break;
            case 'F' :
                float floatValue = orbStream.read_float();
                fieldToValueMap.put(fields[i].getName(),
                                    new Float(floatValue));
                break;
            case 'D' :
                double doubleValue = orbStream.read_double();
                fieldToValueMap.put(fields[i].getName(),
                                    new Double(doubleValue));
                break;
            default:
                // XXX I18N, logging needed.
                throw new InvalidClassException(currentClassDesc.getName());
        }
    }

    /* Read and set object fields from the input stream. */
    if (currentClassDesc.objFields > 0) {
        for (int i = primFields; i < fields.length; i++) {
            Object objectValue = null;
            try {
                objectValue = inputObjectField(fields[i]);
            } catch(IndirectionException cdrie) {
                // The CDR stream had never seen the given offset before,
                // so check the recursion manager (it will throw an
                // IOException if it doesn't have a reference, either).
                objectValue = activeRecursionMgr.getObject(cdrie.offset);
            }

            fieldToValueMap.put(fields[i].getName(), objectValue);
        }
    }
}
 
源代码28 项目: jdk8u60   文件: IIOPInputStream.java
private void inputClassFields(Object o, Class cl,
                              ObjectStreamField[] fields,
                              com.sun.org.omg.SendingContext.CodeBase sender)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IOException
{

    int primFields = fields.length - currentClassDesc.objFields;

    if (o != null) {
        for (int i = 0; i < primFields; ++i) {
            inputPrimitiveField(o, cl, fields[i]);
        }
    }

    /* Read and set object fields from the input stream. */
    if (currentClassDesc.objFields > 0) {
        for (int i = primFields; i < fields.length; i++) {
            Object objectValue = null;

            try {
                objectValue = inputObjectField(fields[i]);
            } catch(IndirectionException cdrie) {
                // The CDR stream had never seen the given offset before,
                // so check the recursion manager (it will throw an
                // IOException if it doesn't have a reference, either).
                objectValue = activeRecursionMgr.getObject(cdrie.offset);
            }

            if ((o == null) || (fields[i].getField() == null)) {
                continue;
            }

            try {
                Class fieldCl = fields[i].getClazz();
                if (objectValue != null && !fieldCl.isInstance(objectValue)) {
                    throw new IllegalArgumentException();
                }
                bridge.putObject( o, fields[i].getFieldID(), objectValue ) ;
                // reflective code: fields[i].getField().set( o, objectValue ) ;
            } catch (IllegalArgumentException e) {
                ClassCastException exc = new ClassCastException("Assigning instance of class " +
                                             objectValue.getClass().getName() +
                                             " to field " +
                                             currentClassDesc.getName() +
                                             '#' +
                                             fields[i].getField().getName());
                exc.initCause( e ) ;
                throw exc ;
            }
        } // end : for loop
        }
    }
 
源代码29 项目: JDKSourceCode1.8   文件: IIOPInputStream.java
/**
 * Override the actions of the final method "readObject()"
 * in ObjectInputStream.
 * @since     JDK1.1.6
 *
 * Read an object from the ObjectInputStream.
 * The class of the object, the signature of the class, and the values
 * of the non-transient and non-static fields of the class and all
 * of its supertypes are read.  Default deserializing for a class can be
 * overriden using the writeObject and readObject methods.
 * Objects referenced by this object are read transitively so
 * that a complete equivalent graph of objects is reconstructed by readObject. <p>
 *
 * The root object is completly restored when all of its fields
 * and the objects it references are completely restored.  At this
 * point the object validation callbacks are executed in order
 * based on their registered priorities. The callbacks are
 * registered by objects (in the readObject special methods)
 * as they are individually restored.
 *
 * Exceptions are thrown for problems with the InputStream and for classes
 * that should not be deserialized.  All exceptions are fatal to the
 * InputStream and leave it in an indeterminate state; it is up to the caller
 * to ignore or recover the stream state.
 * @exception java.lang.ClassNotFoundException Class of a serialized object
 *      cannot be found.
 * @exception InvalidClassException Something is wrong with a class used by
 *     serialization.
 * @exception StreamCorruptedException Control information in the
 *     stream is inconsistent.
 * @exception OptionalDataException Primitive data was found in the
 * stream instead of objects.
 * @exception IOException Any of the usual Input/Output related exceptions.
 * @since     JDK1.1
 */
public final synchronized Object readObjectDelegate() throws IOException
{
    try {

        readObjectState.readData(this);

        return orbStream.read_abstract_interface();
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, true);
        throw marshalException;
    } catch(IndirectionException cdrie)
        {
            // The CDR stream had never seen the given offset before,
            // so check the recursion manager (it will throw an
            // IOException if it doesn't have a reference, either).
            return activeRecursionMgr.getObject(cdrie.offset);
        }
}
 
源代码30 项目: JDKSourceCode1.8   文件: IIOPInputStream.java
private Object inputObjectField(org.omg.CORBA.ValueMember field,
                                com.sun.org.omg.SendingContext.CodeBase sender)
    throws IndirectionException, ClassNotFoundException, IOException,
           StreamCorruptedException {

    Object objectValue = null;
    Class type = null;
    String id = field.id;

    try {
        type = vhandler.getClassFromType(id);
    } catch(ClassNotFoundException cnfe) {
        // Make sure type = null
        type = null;
    }

    String signature = null;
    if (type != null)
        signature = ValueUtility.getSignature(field);

    if (signature != null && (signature.equals("Ljava/lang/Object;") ||
                              signature.equals("Ljava/io/Serializable;") ||
                              signature.equals("Ljava/io/Externalizable;"))) {
        objectValue = javax.rmi.CORBA.Util.readAny(orbStream);
    } else {
        // Decide what method call to make based on the type. If
        // it is a type for which we need to load a stub, convert
        // the type to the correct stub type.
        //
        // NOTE : Since FullValueDescription does not allow us
        // to ask whether something is an interface we do not
        // have the ability to optimize this check.

        int callType = ValueHandlerImpl.kValueType;

        if (!vhandler.isSequence(id)) {

            if (field.type.kind().value() == kRemoteTypeCode.kind().value()) {

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

            } else {

                // REVISIT.  If we don't have the local class,
                // we should probably verify that it's an RMI type,
                // query the remote FVD, and use is_abstract.
                // Our FVD seems to get NullPointerExceptions for any
                // non-RMI types.

                // This uses the local class in the same way as
                // inputObjectField(ObjectStreamField) does.  REVISIT
                // inputObjectField(ObjectStreamField)'s loadStubClass
                // logic.  Assumption is that the given type cannot
                // evolve to become a CORBA abstract interface or
                // a RMI abstract interface.

                if (type != null && type.isInterface() &&
                    (vhandler.isAbstractBase(type) ||
                     ObjectStreamClassCorbaExt.isAbstractInterface(type))) {

                    callType = ValueHandlerImpl.kAbstractType;
                }
            }
        }

        // Now that we have used the FVD of the field to determine the proper course
        // of action, it is ok to use the type (Class) from this point forward since
        // the rep. id for this read will also follow on the wire.

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

    return objectValue;
}
 
 类所在包
 类方法
 同包方法