Skip to main content

StreamCorruptedException

java.io.StreamCorruptedException

StreamCorruptedException is described in the javadoc comments as:

Thrown when control information that was read from an object stream violates internal consistency checks.
author: unascribed version: 1.14, 12/19/03 since: JDK1.1

Where is this exception thrown?

Following, is a list of exception messages cross-referenced to the source code responsible for throwing them. Click on the method link to view the code and see how the exception is thrown.

How is this exception thrown?

The following sub-sections identify where this exception is thrown, and how (or why) the code is throwing the exception.

Any source code quoted in this section is subject to the Java Research License unless stated otherwise.

java.io.ObjectInputStream.readArray(boolean)

/**
     * Reads in and returns array object, or null if array class is
     * unresolvable.  Sets passHandle to array's assigned handle.
     */
private Object readArray(boolean unshared) throws IOException {
    if (bin.readByte() != TC_ARRAY) {
        throw new StreamCorruptedException();
    }
    ObjectStreamClass desc = readClassDesc(false);
    int len = bin.readInt();
    Object array = null;
    Class cl, ccl = null;
    if ((cl = desc.forClass()) != null) {
        ccl = cl.getComponentType();
        array = Array.newInstance(ccl, len);
    }
    int arrayHandle = handles.assign(unshared ? unsharedMarker : array);
    ClassNotFoundException resolveEx = desc.getResolveException();
    if (resolveEx != null) {
        handles.markException(arrayHandle, resolveEx);
    }
    if (ccl == null) {
        for (int i = 0; i < len; i++) {
            readObject0(false);
        }
    } else if (ccl.isPrimitive()) {
        if (ccl == Integer.TYPE) {
            bin.readInts((int[]) array, 0, len);
        } else if (ccl == Byte.TYPE) {
            bin.readFully((byte[]) array, 0, len, true);
        } else if (ccl == Long.TYPE) {
            bin.readLongs((long[]) array, 0, len);
        } else if (ccl == Float.TYPE) {
            bin.readFloats((float[]) array, 0, len);
        } else if (ccl == Double.TYPE) {
            bin.readDoubles((double[]) array, 0, len);
        } else if (ccl == Short.TYPE) {
            bin.readShorts((short[]) array, 0, len);
        } else if (ccl == Character.TYPE) {
            bin.readChars((char[]) array, 0, len);
        } else if (ccl == Boolean.TYPE) {
            bin.readBooleans((boolean[]) array, 0, len);
        } else {
            throw new InternalError();
        }
    } else {
        Object[] oa = (Object[]) array;
        for (int i = 0; i < len; i++) {
            oa[i] = readObject0(false);
            handles.markDependency(arrayHandle, passHandle);
        }
    }
    handles.finish(arrayHandle);
    passHandle = arrayHandle;
    return array;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.ObjectInputStream.readClass(boolean)

/**
     * Reads in and returns class object.  Sets passHandle to class object's
     * assigned handle.  Returns null if class is unresolvable (in which case a
     * ClassNotFoundException will be associated with the class' handle in the
     * handle table).
     */
private Class readClass(boolean unshared) throws IOException {
    if (bin.readByte() != TC_CLASS) {
        throw new StreamCorruptedException();
    }
    ObjectStreamClass desc = readClassDesc(false);
    Class cl = desc.forClass();
    passHandle = handles.assign(unshared ? unsharedMarker : cl);
    ClassNotFoundException resolveEx = desc.getResolveException();
    if (resolveEx != null) {
        handles.markException(passHandle, resolveEx);
    }
    handles.finish(passHandle);
    return cl;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.ObjectInputStream.readClassDesc(boolean)

/**
     * Reads in and returns (possibly null) class descriptor.  Sets passHandle
     * to class descriptor's assigned handle.  If class descriptor cannot be
     * resolved to a class in the local VM, a ClassNotFoundException is
     * associated with the class descriptor's handle.
     */
private ObjectStreamClass readClassDesc(boolean unshared) throws IOException {
    switch(bin.peekByte()) {
        case TC_NULL:
            return (ObjectStreamClass) readNull();
        case TC_REFERENCE:
            return (ObjectStreamClass) readHandle(unshared);
        case TC_PROXYCLASSDESC:
            return readProxyDesc(unshared);
        case TC_CLASSDESC:
            return readNonProxyDesc(unshared);
        default:
            throw new StreamCorruptedException();
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.ObjectInputStream.readEnum(boolean)

/**
     * Reads in and returns enum constant, or null if enum type is
     * unresolvable.  Sets passHandle to enum constant's assigned handle.
     */
private Enum readEnum(boolean unshared) throws IOException {
    if (bin.readByte() != TC_ENUM) {
        throw new StreamCorruptedException();
    }
    ObjectStreamClass desc = readClassDesc(false);
    if (!desc.isEnum()) {
        throw new InvalidClassException('non-enum class: ' + desc);
    }
    int enumHandle = handles.assign(unshared ? unsharedMarker : null);
    ClassNotFoundException resolveEx = desc.getResolveException();
    if (resolveEx != null) {
        handles.markException(enumHandle, resolveEx);
    }
    String name = readString(false);
    Enum en = null;
    Class cl = desc.forClass();
    if (cl != null) {
        try {
            en = Enum.valueOf(cl, name);
        } catch (IllegalArgumentException ex) {
            throw (IOException) new InvalidObjectException('enum constant ' + name + ' does not exist in ' + cl).initCause(ex);
        }
        if (!unshared) {
            handles.setObject(enumHandle, en);
        }
    }
    handles.finish(enumHandle);
    passHandle = enumHandle;
    return en;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.ObjectInputStream.readFatalException()

/**
     * Reads in and returns IOException that caused serialization to abort.
     * All stream state is discarded prior to reading in fatal exception.  Sets
     * passHandle to fatal exception's handle.
     */
private IOException readFatalException() throws IOException {
    if (bin.readByte() != TC_EXCEPTION) {
        throw new StreamCorruptedException();
    }
    clear();
    return (IOException) readObject0(false);
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.ObjectInputStream.readHandle(boolean)

/**
     * Reads in object handle, sets passHandle to the read handle, and returns
     * object associated with the handle.
     */
private Object readHandle(boolean unshared) throws IOException {
    if (bin.readByte() != TC_REFERENCE) {
        throw new StreamCorruptedException();
    }
    passHandle = bin.readInt() - baseWireHandle;
    if (passHandle < 0 || passHandle >= handles.size()) {
        throw new StreamCorruptedException('illegal handle value');
    }
    if (unshared) {
        throw new InvalidObjectException('cannot read back reference as unshared');
    }
    Object obj = handles.lookupObject(passHandle);
    if (obj == unsharedMarker) {
        throw new InvalidObjectException('cannot read back reference to unshared object');
    }
    return obj;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.ObjectInputStream.readNonProxyDesc(boolean)

/**
     * Reads in and returns class descriptor for a class that is not a dynamic
     * proxy class.  Sets passHandle to class descriptor's assigned handle.  If
     * class descriptor cannot be resolved to a class in the local VM, a
     * ClassNotFoundException is associated with the descriptor's handle.
     */
private ObjectStreamClass readNonProxyDesc(boolean unshared) throws IOException {
    if (bin.readByte() != TC_CLASSDESC) {
        throw new StreamCorruptedException();
    }
    ObjectStreamClass desc = new ObjectStreamClass();
    int descHandle = handles.assign(unshared ? unsharedMarker : desc);
    passHandle = NULL_HANDLE;
    ObjectStreamClass readDesc = null;
    try {
        readDesc = readClassDescriptor();
    } catch (ClassNotFoundException ex) {
        throw (IOException) new InvalidClassException('failed to read class descriptor').initCause(ex);
    }
    Class cl = null;
    ClassNotFoundException resolveEx = null;
    bin.setBlockDataMode(true);
    try {
        if ((cl = resolveClass(readDesc)) == null) {
            throw new ClassNotFoundException('null class');
        }
    } catch (ClassNotFoundException ex) {
        resolveEx = ex;
    }
    skipCustomData();
    desc.initNonProxy(readDesc, cl, resolveEx, readClassDesc(false));
    handles.finish(descHandle);
    passHandle = descHandle;
    return desc;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.ObjectInputStream.readNull()

/**
     * Reads in null code, sets passHandle to NULL_HANDLE and returns null.
     */
private Object readNull() throws IOException {
    if (bin.readByte() != TC_NULL) {
        throw new StreamCorruptedException();
    }
    passHandle = NULL_HANDLE;
    return null;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.ObjectInputStream.readObject0(boolean)

/**
     * Underlying readObject implementation.
     */
private Object readObject0(boolean unshared) throws IOException {
    boolean oldMode = bin.getBlockDataMode();
    if (oldMode) {
        int remain = bin.currentBlockRemaining();
        if (remain > 0) {
            throw new OptionalDataException(remain);
        } else if (defaultDataEnd) {
            throw new OptionalDataException(true);
        }
        bin.setBlockDataMode(false);
    }
    byte tc;
    while ((tc = bin.peekByte()) == TC_RESET) {
        bin.readByte();
        handleReset();
    }
    depth++;
    try {
        switch(tc) {
            case TC_NULL:
                return readNull();
            case TC_REFERENCE:
                return readHandle(unshared);
            case TC_CLASS:
                return readClass(unshared);
            case TC_CLASSDESC:
            case TC_PROXYCLASSDESC:
                return readClassDesc(unshared);
            case TC_STRING:
            case TC_LONGSTRING:
                return checkResolve(readString(unshared));
            case TC_ARRAY:
                return checkResolve(readArray(unshared));
            case TC_ENUM:
                return checkResolve(readEnum(unshared));
            case TC_OBJECT:
                return checkResolve(readOrdinaryObject(unshared));
            case TC_EXCEPTION:
                IOException ex = readFatalException();
                throw new WriteAbortedException('writing aborted', ex);
            case TC_BLOCKDATA:
            case TC_BLOCKDATALONG:
                if (oldMode) {
                    bin.setBlockDataMode(true);
                    bin.peek();
                    throw new OptionalDataException(bin.currentBlockRemaining());
                } else {
                    throw new StreamCorruptedException('unexpected block data');
                }
            case TC_ENDBLOCKDATA:
                if (oldMode) {
                    throw new OptionalDataException(true);
                } else {
                    throw new StreamCorruptedException('unexpected end of block data');
                }
            default:
                throw new StreamCorruptedException();
        }
    } finally {
        depth--;
        bin.setBlockDataMode(oldMode);
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.ObjectInputStream.readOrdinaryObject(boolean)

/**
     * Reads and returns 'ordinary' (i.e., not a String, Class,
     * ObjectStreamClass, array, or enum constant) object, or null if object's
     * class is unresolvable (in which case a ClassNotFoundException will be
     * associated with object's handle).  Sets passHandle to object's assigned
     * handle.
     */
private Object readOrdinaryObject(boolean unshared) throws IOException {
    if (bin.readByte() != TC_OBJECT) {
        throw new StreamCorruptedException();
    }
    ObjectStreamClass desc = readClassDesc(false);
    desc.checkDeserialize();
    Object obj;
    try {
        obj = desc.isInstantiable() ? desc.newInstance() : null;
    } catch (Exception ex) {
        throw new InvalidClassException(desc.forClass().getName(), 'unable to create instance');
    }
    passHandle = handles.assign(unshared ? unsharedMarker : obj);
    ClassNotFoundException resolveEx = desc.getResolveException();
    if (resolveEx != null) {
        handles.markException(passHandle, resolveEx);
    }
    if (desc.isExternalizable()) {
        readExternalData((Externalizable) obj, desc);
    } else {
        readSerialData(obj, desc);
    }
    handles.finish(passHandle);
    if (obj != null && handles.lookupException(passHandle) == null && desc.hasReadResolveMethod()) {
        Object rep = desc.invokeReadResolve(obj);
        if (rep != obj) {
            handles.setObject(passHandle, obj = rep);
        }
    }
    return obj;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.ObjectInputStream.readProxyDesc(boolean)

/**
     * Reads in and returns class descriptor for a dynamic proxy class.  Sets
     * passHandle to proxy class descriptor's assigned handle.  If proxy class
     * descriptor cannot be resolved to a class in the local VM, a
     * ClassNotFoundException is associated with the descriptor's handle.
     */
private ObjectStreamClass readProxyDesc(boolean unshared) throws IOException {
    if (bin.readByte() != TC_PROXYCLASSDESC) {
        throw new StreamCorruptedException();
    }
    ObjectStreamClass desc = new ObjectStreamClass();
    int descHandle = handles.assign(unshared ? unsharedMarker : desc);
    passHandle = NULL_HANDLE;
    int numIfaces = bin.readInt();
    String[] ifaces = new String[numIfaces];
    for (int i = 0; i < numIfaces; i++) {
        ifaces[i] = bin.readUTF();
    }
    Class cl = null;
    ClassNotFoundException resolveEx = null;
    bin.setBlockDataMode(true);
    try {
        if ((cl = resolveProxyClass(ifaces)) == null) {
            throw new ClassNotFoundException('null class');
        }
    } catch (ClassNotFoundException ex) {
        resolveEx = ex;
    }
    skipCustomData();
    desc.initProxy(cl, resolveEx, readClassDesc(false));
    handles.finish(descHandle);
    passHandle = descHandle;
    return desc;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.ObjectInputStream.readString(boolean)

/**
     * Reads in and returns new string.  Sets passHandle to new string's
     * assigned handle.
     */
private String readString(boolean unshared) throws IOException {
    String str;
    switch(bin.readByte()) {
        case TC_STRING:
            str = bin.readUTF();
            break;
        case TC_LONGSTRING:
            str = bin.readLongUTF();
            break;
        default:
            throw new StreamCorruptedException();
    }
    passHandle = handles.assign(unshared ? unsharedMarker : str);
    handles.finish(passHandle);
    return str;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.ObjectInputStream.readTypeString()

/**
     * Reads string without allowing it to be replaced in stream.  Called from
     * within ObjectStreamClass.read().
     */
String readTypeString() throws IOException {
    int oldHandle = passHandle;
    try {
        switch(bin.peekByte()) {
            case TC_NULL:
                return (String) readNull();
            case TC_REFERENCE:
                return (String) readHandle(false);
            case TC_STRING:
            case TC_LONGSTRING:
                return readString(false);
            default:
                throw new StreamCorruptedException();
        }
    } finally {
        passHandle = oldHandle;
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

com.sun.corba.se.impl.io.IIOPInputStream.inputObjectField(ObjectStreamField)

/**
     * Factored out of inputClassFields and reused in 
     * inputCurrentClassFieldsForReadFields.
     * Reads the field (which of an Object type as opposed to a primitive) 
     * described by ObjectStreamField field and returns it.
     */
private Object inputObjectField(ObjectStreamField field) throws InvalidClassException, StreamCorruptedException, ClassNotFoundException, IndirectionException, IOException {
    if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
        return javax.rmi.CORBA.Util.readAny(orbStream);
    }
    Object objectValue = null;
    Class fieldType = field.getType();
    Class actualType = fieldType;
    int callType = ValueHandlerImpl.kValueType;
    boolean narrow = false;
    if (fieldType.isInterface()) {
        boolean loadStubClass = false;
        if (java.rmi.Remote.class.isAssignableFrom(fieldType)) {
            callType = ValueHandlerImpl.kRemoteType;
        } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)) {
            callType = ValueHandlerImpl.kRemoteType;
            loadStubClass = true;
        } else if (vhandler.isAbstractBase(fieldType)) {
            callType = ValueHandlerImpl.kAbstractType;
            loadStubClass = true;
        } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) {
            callType = ValueHandlerImpl.kAbstractType;
        }
        if (loadStubClass) {
            try {
                String codebase = Util.getCodebase(fieldType);
                String repID = vhandler.createForAnyType(fieldType);
                Class stubType = Utility.loadStubClass(repID, codebase, fieldType);
                actualType = stubType;
            } catch (ClassNotFoundException e) {
                narrow = true;
            }
        } else {
            narrow = true;
        }
    }
    switch(callType) {
        case ValueHandlerImpl.kRemoteType:
            if (!narrow) objectValue = (Object) orbStream.read_Object(actualType); else objectValue = Utility.readObjectAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kAbstractType:
            if (!narrow) objectValue = (Object) orbStream.read_abstract_interface(actualType); else objectValue = Utility.readAbstractAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kValueType:
            objectValue = (Object) orbStream.read_value(actualType);
            break;
        default:
            throw new StreamCorruptedException('Unknown callType: ' + callType);
    }
    return objectValue;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

com.sun.corba.se.impl.io.IIOPInputStream.inputObjectField(org.omg.CORBA.ValueMember, com.sun.org.omg.SendingContext.CodeBase)

private Object inputObjectField(org.omg.CORBA.ValueMember field, com.sun.org.omg.SendingContext.CodeBase sender) throws IndirectionException, ClassNotFoundException, IOException, StreamCorruptedException {
    Object objectValue = null;
    Class type = null;
    String id = field.id;
    try {
        type = vhandler.getClassFromType(id);
    } catch (ClassNotFoundException cnfe) {
        type = null;
    }
    String signature = null;
    if (type != null) signature = ValueUtility.getSignature(field);
    if (signature != null && (signature.equals('Ljava/lang/Object;') || signature.equals('Ljava/io/Serializable;') || signature.equals('Ljava/io/Externalizable;'))) {
        objectValue = javax.rmi.CORBA.Util.readAny(orbStream);
    } else {
        int callType = ValueHandlerImpl.kValueType;
        if (!vhandler.isSequence(id)) {
            if (field.type.kind().value() == kRemoteTypeCode.kind().value()) {
                callType = ValueHandlerImpl.kRemoteType;
            } else {
                if (type != null && type.isInterface() && (vhandler.isAbstractBase(type) || ObjectStreamClassCorbaExt.isAbstractInterface(type))) {
                    callType = ValueHandlerImpl.kAbstractType;
                }
            }
        }
        switch(callType) {
            case ValueHandlerImpl.kRemoteType:
                if (type != null) objectValue = Utility.readObjectAndNarrow(orbStream, type); else objectValue = orbStream.read_Object();
                break;
            case ValueHandlerImpl.kAbstractType:
                if (type != null) objectValue = Utility.readAbstractAndNarrow(orbStream, type); else objectValue = orbStream.read_abstract_interface();
                break;
            case ValueHandlerImpl.kValueType:
                if (type != null) objectValue = orbStream.read_value(type); else objectValue = orbStream.read_value();
                break;
            default:
                throw new StreamCorruptedException('Unknown callType: ' + callType);
        }
    }
    return objectValue;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

com.sun.corba.se.impl.io.IIOPInputStream.throwAwayData(ValueMember[], com.sun.org.omg.SendingContext.CodeBase)

private void throwAwayData(ValueMember[] fields, com.sun.org.omg.SendingContext.CodeBase sender) throws InvalidClassException, StreamCorruptedException, ClassNotFoundException, IOException {
    for (int i = 0; i < fields.length; ++i) {
        try {
            switch(fields[i].type.kind().value()) {
                case TCKind._tk_octet:
                    orbStream.read_octet();
                    break;
                case TCKind._tk_boolean:
                    orbStream.read_boolean();
                    break;
                case TCKind._tk_char:
                case TCKind._tk_wchar:
                    orbStream.read_wchar();
                    break;
                case TCKind._tk_short:
                    orbStream.read_short();
                    break;
                case TCKind._tk_long:
                    orbStream.read_long();
                    break;
                case TCKind._tk_longlong:
                    orbStream.read_longlong();
                    break;
                case TCKind._tk_float:
                    orbStream.read_float();
                    break;
                case TCKind._tk_double:
                    orbStream.read_double();
                    break;
                case TCKind._tk_value:
                case TCKind._tk_objref:
                case TCKind._tk_value_box:
                    Class type = null;
                    String id = fields[i].id;
                    try {
                        type = vhandler.getClassFromType(id);
                    } catch (ClassNotFoundException cnfe) {
                        type = null;
                    }
                    String signature = null;
                    if (type != null) signature = ValueUtility.getSignature(fields[i]);
                    try {
                        if ((signature != null) && (signature.equals('Ljava/lang/Object;') || signature.equals('Ljava/io/Serializable;') || signature.equals('Ljava/io/Externalizable;'))) {
                            javax.rmi.CORBA.Util.readAny(orbStream);
                        } else {
                            int callType = ValueHandlerImpl.kValueType;
                            if (!vhandler.isSequence(id)) {
                                FullValueDescription fieldFVD = sender.meta(fields[i].id);
                                if (kRemoteTypeCode == fields[i].type) {
                                    callType = ValueHandlerImpl.kRemoteType;
                                } else if (fieldFVD.is_abstract) {
                                    callType = ValueHandlerImpl.kAbstractType;
                                }
                            }
                            switch(callType) {
                                case ValueHandlerImpl.kRemoteType:
                                    orbStream.read_Object();
                                    break;
                                case ValueHandlerImpl.kAbstractType:
                                    orbStream.read_abstract_interface();
                                    break;
                                case ValueHandlerImpl.kValueType:
                                    if (type != null) {
                                        orbStream.read_value(type);
                                    } else {
                                        orbStream.read_value();
                                    }
                                    break;
                                default:
                                    throw new StreamCorruptedException('Unknown callType: ' + callType);
                            }
                        }
                    } catch (IndirectionException cdrie) {
                        continue;
                    }
                    break;
                default:
                    throw new StreamCorruptedException('Unknown kind: ' + fields[i].type.kind().value());
            }
        } catch (IllegalArgumentException e) {
            ClassCastException cce = new ClassCastException('Assigning instance of class ' + fields[i].id + ' to field ' + currentClassDesc.getName() + '#' + fields[i].name);
            cce.initCause(e);
            throw cce;
        }
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

com.sun.corba.se.impl.io.IIOPInputStream.inputClassFields(Object, Class, ObjectStreamClass, ValueMember[], com.sun.org.omg.SendingContext.CodeBase)

private void inputClassFields(Object o, Class cl, ObjectStreamClass osc, ValueMember[] fields, com.sun.org.omg.SendingContext.CodeBase sender) throws InvalidClassException, StreamCorruptedException, ClassNotFoundException, IOException {
    try {
        for (int i = 0; i < fields.length; ++i) {
            try {
                switch(fields[i].type.kind().value()) {
                    case TCKind._tk_octet:
                        byte byteValue = orbStream.read_octet();
                        if ((o != null) && osc.hasField(fields[i])) setByteField(o, cl, fields[i].name, byteValue);
                        break;
                    case TCKind._tk_boolean:
                        boolean booleanValue = orbStream.read_boolean();
                        if ((o != null) && osc.hasField(fields[i])) setBooleanField(o, cl, fields[i].name, booleanValue);
                        break;
                    case TCKind._tk_char:
                    case TCKind._tk_wchar:
                        char charValue = orbStream.read_wchar();
                        if ((o != null) && osc.hasField(fields[i])) setCharField(o, cl, fields[i].name, charValue);
                        break;
                    case TCKind._tk_short:
                        short shortValue = orbStream.read_short();
                        if ((o != null) && osc.hasField(fields[i])) setShortField(o, cl, fields[i].name, shortValue);
                        break;
                    case TCKind._tk_long:
                        int intValue = orbStream.read_long();
                        if ((o != null) && osc.hasField(fields[i])) setIntField(o, cl, fields[i].name, intValue);
                        break;
                    case TCKind._tk_longlong:
                        long longValue = orbStream.read_longlong();
                        if ((o != null) && osc.hasField(fields[i])) setLongField(o, cl, fields[i].name, longValue);
                        break;
                    case TCKind._tk_float:
                        float floatValue = orbStream.read_float();
                        if ((o != null) && osc.hasField(fields[i])) setFloatField(o, cl, fields[i].name, floatValue);
                        break;
                    case TCKind._tk_double:
                        double doubleValue = orbStream.read_double();
                        if ((o != null) && osc.hasField(fields[i])) setDoubleField(o, cl, fields[i].name, doubleValue);
                        break;
                    case TCKind._tk_value:
                    case TCKind._tk_objref:
                    case TCKind._tk_value_box:
                        Object objectValue = null;
                        try {
                            objectValue = inputObjectField(fields[i], sender);
                        } catch (IndirectionException cdrie) {
                            objectValue = activeRecursionMgr.getObject(cdrie.offset);
                        }
                        if (o == null) continue;
                        try {
                            if (osc.hasField(fields[i])) {
                                setObjectField(o, cl, fields[i].name, objectValue);
                            } else {
                            }
                        } catch (IllegalArgumentException e) {
                            ClassCastException cce = new ClassCastException('Assigning instance of class ' + objectValue.getClass().getName() + ' to field ' + fields[i].name);
                            cce.initCause(e);
                            throw cce;
                        }
                        break;
                    default:
                        throw new StreamCorruptedException('Unknown kind: ' + fields[i].type.kind().value());
                }
            } catch (IllegalArgumentException e) {
                ClassCastException cce = new ClassCastException('Assigning instance of class ' + fields[i].id + ' to field ' + currentClassDesc.getName() + '#' + fields[i].name);
                cce.initCause(e);
                throw cce;
            }
        }
    } catch (Throwable t) {
        StreamCorruptedException sce = new StreamCorruptedException(t.getMessage());
        sce.initCause(t);
        throw sce;
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

com.sun.corba.se.impl.io.IIOPInputStream.inputRemoteMembersForReadFields(java.util.Map)

private final void inputRemoteMembersForReadFields(java.util.Map fieldToValueMap) throws InvalidClassException, StreamCorruptedException, ClassNotFoundException, IOException {
    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:
                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) {
                        objectValue = activeRecursionMgr.getObject(cdrie.offset);
                    }
                    fieldToValueMap.put(fields[i].name, objectValue);
                    break;
                default:
                    throw new StreamCorruptedException('Unknown kind: ' + fields[i].type.kind().value());
            }
        }
    } catch (Throwable t) {
        StreamCorruptedException result = new StreamCorruptedException(t.getMessage());
        result.initCause(t);
        throw result;
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.ObjectInputStream.readStreamHeader()

/**
     * The readStreamHeader method is provided to allow subclasses to read and
     * verify their own stream headers. It reads and verifies the magic number
     * and version number.
     * @throws IOException if there are I/O errors while reading from the
     *   underlying <code>InputStream</code> 
     * @throws StreamCorruptedException if control information in the stream
     *   is inconsistent
     */
protected void readStreamHeader() throws IOException, StreamCorruptedException {
    if (bin.readShort() != STREAM_MAGIC || bin.readShort() != STREAM_VERSION) {
        throw new StreamCorruptedException('invalid stream header');
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.ObjectInputStream.handleReset()

/**
     * If recursion depth is 0, clears internal data structures; otherwise,
     * throws a StreamCorruptedException.  This method is called when a
     * TC_RESET typecode is encountered.
     */
private void handleReset() throws StreamCorruptedException {
    if (depth > 0) {
        throw new StreamCorruptedException('unexpected reset');
    }
    clear();
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Comments

Popular posts from this blog

NullPointerException

java.lang.NullPointerException NullPointerException is described in the javadoc comments as: Thrown when an application attempts to use null in a case where an object is required. These include: Calling the instance method of a null object. Accessing or modifying the field of a null object. Taking the length of null as if it were an array. Accessing or modifying the slots of null as if it were an array. Throwing null as if it were a Throwable value. Applications should throw instances of this class to indicate other illegal uses of the null object. author: unascribed version: 1.19, 12/19/03 since: JDK1.0 Where is this exception thrown? Following, is a list of exception messages cross-referenced to the source code responsible for throwing them. Click on the method link to view the code and see how the exception is thrown. The message ' java.lang.NullPointerException: ' is thrown within the method: com.sun.corba.se.impl.interceptors.ClientRequestInfoImpl.get_r

Connection refused: No available router to destination

This is a simple symptom-cause-solution blog entry only. I hope these blogs will help fellow administrators. Symptom The following exception occurs in WebLogic server logs. Most likely to occur during WebLogic server start-up, but similar exceptions may occur at other times. java.net.ConnectException: t3://myserver:8000: Destination unreachable; nested exception is: java.net.ConnectException: Connection refused: connect; No available router to destination] at weblogic.jndi.internal.ExceptionTranslator.toNamingException(ExceptionTranslator.java:49) at weblogic.jndi.WLInitialContextFactoryDelegate.toNamingException(WLInitialContextFactoryDelegate.java:773) at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:363) at weblogic.jndi.Environment.getContext(Environment.java:307) at weblogic.jndi.Environment.getContext(Environment.java:277) Cause This message (Connection refused: connect; No available

Recovering WebLogic Passwords

In one of my previous articles ( here ) I explained that the SerializedSystemIni.dat file in WebLogic contains the key used to encrypt and decrypt passwords. If you're not currently keeping this file secure I suggest you do, as with it someone can (to name a few things): Decrypt the WebLogic admin username and password from boot.properties. Recover database passwords, if JDBC Connection pools are configured, from config.xml. Recover the keystore passwords from config.xml and obtain SSL certificates stored in the jks keystores. Essentially, they can do whatever they want, so if you don't know who can read your SerializedSystemIni.dat files, look... now. In this article I will show how easy it is for this file to be used to recover lost passwords via a simple WLST script. The Script The script I use to decrypt passwords is incredibly short, and it works with WebLogic 8, 9 and 10 (probably for version 7 too). To use it, just create a new file called decryptpwd.py and paste the fol