Java Code Examples for java.io.StreamCorruptedException#initCause()

The following examples show how to use java.io.StreamCorruptedException#initCause() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IIOPInputStream.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
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 2
Source File: IIOPInputStream.java    From TencentKona-8 with GNU General Public License v2.0 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 3
Source File: IIOPInputStream.java    From jdk8u60 with GNU General Public License v2.0 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 4
Source File: IIOPInputStream.java    From JDKSourceCode1.8 with MIT License 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 5
Source File: IIOPInputStream.java    From openjdk-jdk8u with GNU General Public License v2.0 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 6
Source File: IIOPInputStream.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 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 7
Source File: IIOPInputStream.java    From openjdk-jdk9 with GNU General Public License v2.0 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 8
Source File: IIOPInputStream.java    From hottub with GNU General Public License v2.0 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 9
Source File: IIOPInputStream.java    From openjdk-8-source with GNU General Public License v2.0 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 10
Source File: IIOPInputStream.java    From openjdk-8 with GNU General Public License v2.0 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 11
Source File: FormatIdInputStream.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
  Read an object from this stream.

  @return The read object.
  @exception java.io.IOException An IO or serialization error occured.
  @exception java.lang.ClassNotFoundException A class for an object in
  the stream could not be found.
  */

public Object readObject() throws IOException, ClassNotFoundException
{
       setErrorInfo(null);

	int fmtId = FormatIdUtil.readFormatIdInteger(this);

	if (fmtId == StoredFormatIds.NULL_FORMAT_ID)
	{
		return null;
	}

	if (fmtId == StoredFormatIds.STRING_FORMAT_ID)
	{
		return readUTF();
	}

	try
       {

		if (fmtId == StoredFormatIds.SERIALIZABLE_FORMAT_ID)
		{
			ObjectInputStream ois = getObjectStream();
			try {
				return ois.readObject();
			} catch (IOException | ClassCastException | LinkageError | ClassNotFoundException ioe) {
				setErrorInfo((ErrorInfo) ois);
				throw ioe;
			}
           }

		try {

			Formatable f = (Formatable)Monitor.newInstanceFromIdentifier(fmtId);
			if (f instanceof Storable)
			{
				boolean isNull = this.readBoolean();
				if (isNull)
				{
					Storable s = (Storable)f;
					s.restoreToNull();
					return s;
				}
			}

			f.readExternal(this);
			return f;
		} catch (StandardException se) {
			throw new ClassNotFoundException(se.toString());
		}


	}
       catch (ClassCastException cce)
       {
		// We catch this here as it is usuall a user error.
		// they have readExternal (or SQLData) that doesn't match
		// the writeExternal. and thus the object read is of
		// the incorrect type, e.g. Integer i = (Integer) in.readObject();
		StreamCorruptedException sce = new StreamCorruptedException(cce.toString());
		sce.initCause(cce);
		throw sce;
	}
}