Java Code Examples for org.omg.CORBA.portable.IndirectionException

The following are top voted examples for showing how to use org.omg.CORBA.portable.IndirectionException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OpenJSharp   File: CDRInputStream_1_0.java   View source code 5 votes vote down vote up
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);
    }
}
 
Example 2
Project: openjdk-jdk10   File: CDRInputStream_1_0.java   View source code 5 votes vote down vote up
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);
    }
}
 
Example 3
Project: openjdk9   File: CDRInputStream_1_0.java   View source code 5 votes vote down vote up
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);
    }
}
 
Example 4
Project: lookaside_java-1.8.0-openjdk   File: CDRInputStream_1_0.java   View source code 5 votes vote down vote up
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);
    }
}
 
Example 5
Project: jdk8u_corba   File: CDRInputStream_1_0.java   View source code 5 votes vote down vote up
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);
    }
}
 
Example 6
Project: infobip-open-jdk-8   File: CDRInputStream_1_0.java   View source code 5 votes vote down vote up
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);
    }
}
 
Example 7
Project: openjdk-source-code-learn   File: CDRInputStream_1_0.java   View source code 5 votes vote down vote up
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);
    }
}
 
Example 8
Project: OLD-OpenJDK8   File: CDRInputStream_1_0.java   View source code 5 votes vote down vote up
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);
    }
}
 
Example 9
Project: openjdk-orb   File: CDRInputStream_1_0.java   View source code 5 votes vote down vote up
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);
    }
}
 
Example 10
Project: openjdk-icedtea7   File: CDRInputStream_1_0.java   View source code 5 votes vote down vote up
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);
    }
}
 
Example 11
Project: OpenJSharp   File: IIOPInputStream.java   View source code 4 votes vote down vote up
/**
 * 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);
        }
}
 
Example 12
Project: OpenJSharp   File: IIOPInputStream.java   View source code 4 votes vote down vote up
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;
    }
}
 
Example 13
Project: OpenJSharp   File: IIOPInputStream.java   View source code 4 votes vote down vote up
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) {
            if (fields[i].getField() == null)
                continue;

            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
        }
    }
 
Example 14
Project: openjdk-jdk10   File: IIOPInputStream.java   View source code 4 votes vote down vote up
/**
 * 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);
        }
}
 
Example 15
Project: openjdk-jdk10   File: IIOPInputStream.java   View source code 4 votes vote down vote up
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;
    }
}
 
Example 16
Project: openjdk9   File: IIOPInputStream.java   View source code 4 votes vote down vote up
/**
 * 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);
        }
}
 
Example 17
Project: openjdk9   File: IIOPInputStream.java   View source code 4 votes vote down vote up
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;
    }
}
 
Example 18
Project: openjdk9   File: IIOPInputStream.java   View source code 4 votes vote down vote up
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.isAssignableFrom(
                                objectValue.getClass()))) {
                    throw new IllegalArgumentException("Field mismatch");
                }
               Field classField = null;
                try {
                    classField = cl.getDeclaredField(fields[i].getName());
                } catch (NoSuchFieldException nsfEx) {
                    throw new IllegalArgumentException(nsfEx);
                } catch (SecurityException secEx) {
                    throw new IllegalArgumentException(secEx.getCause());
                }
                Class<?> declaredFieldClass = classField.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 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
        }
    }
 
Example 19
Project: lookaside_java-1.8.0-openjdk   File: IIOPInputStream.java   View source code 4 votes vote down vote up
/**
 * 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);
        }
}
 
Example 20
Project: lookaside_java-1.8.0-openjdk   File: IIOPInputStream.java   View source code 4 votes vote down vote up
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;
    }
}
 
Example 21
Project: jdk8u_corba   File: IIOPInputStream.java   View source code 4 votes vote down vote up
/**
 * 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);
        }
}
 
Example 22
Project: jdk8u_corba   File: IIOPInputStream.java   View source code 4 votes vote down vote up
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;
    }
}
 
Example 23
Project: infobip-open-jdk-8   File: IIOPInputStream.java   View source code 4 votes vote down vote up
/**
 * 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);
        }
}
 
Example 24
Project: infobip-open-jdk-8   File: IIOPInputStream.java   View source code 4 votes vote down vote up
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;
    }
}
 
Example 25
Project: infobip-open-jdk-8   File: IIOPInputStream.java   View source code 4 votes vote down vote up
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) {
            if (fields[i].getField() == null)
                continue;

            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
        }
    }
 
Example 26
Project: openjdk-source-code-learn   File: IIOPInputStream.java   View source code 4 votes vote down vote up
/**
 * 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 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);
        }
}
 
Example 27
Project: openjdk-source-code-learn   File: IIOPInputStream.java   View source code 4 votes vote down vote up
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;
    }
}
 
Example 28
Project: openjdk-source-code-learn   File: IIOPInputStream.java   View source code 4 votes vote down vote up
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) {
            if (fields[i].getField() == null)
                continue;

            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 {
                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
        }
    }
 
Example 29
Project: OLD-OpenJDK8   File: IIOPInputStream.java   View source code 4 votes vote down vote up
/**
 * 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);
        }
}
 
Example 30
Project: OLD-OpenJDK8   File: IIOPInputStream.java   View source code 4 votes vote down vote up
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;
    }
}
 
Example 31
Project: OLD-OpenJDK8   File: IIOPInputStream.java   View source code 4 votes vote down vote up
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) {
            if (fields[i].getField() == null)
                continue;

            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
        }
    }
 
Example 32
Project: openjdk-orb   File: IIOPInputStream.java   View source code 4 votes vote down vote up
/**
 * 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);
        }
}
 
Example 33
Project: openjdk-orb   File: IIOPInputStream.java   View source code 4 votes vote down vote up
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;
    }
}
 
Example 34
Project: openjdk-icedtea7   File: IIOPInputStream.java   View source code 4 votes vote down vote up
/**
 * 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 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);
        }
}
 
Example 35
Project: openjdk-icedtea7   File: IIOPInputStream.java   View source code 4 votes vote down vote up
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;
    }
}
 
Example 36
Project: openjdk-icedtea7   File: IIOPInputStream.java   View source code 4 votes vote down vote up
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) {
            if (fields[i].getField() == null)
                continue;

            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
        }
    }