public Object readObject()

in src/main/java/com/alibaba/com/caucho/hessian/io/HessianInput.java [1016:1091]


    public Object readObject(Class expectedClass, Class<?>... expectedTypes)
            throws IOException {
        if (expectedClass == null || expectedClass == Object.class)
            return readObject();

        int tag = read();

        switch (tag) {
            case 'N':
                return null;

            case 'M': {
                String type = readType();

                boolean keyValuePair = expectedTypes != null && expectedTypes.length == 2;

                // hessian/3386
                if ("".equals(type)) {
                    Deserializer reader;
                    reader = _serializerFactory.getDeserializer(expectedClass);

                    return reader.readMap(this
                            , keyValuePair ? expectedTypes[0] : null
                            , keyValuePair ? expectedTypes[1] : null);
                } else {
                    Deserializer reader;
                    reader = _serializerFactory.getObjectDeserializer(type, expectedClass);

                    return reader.readMap(this
                            , keyValuePair ? expectedTypes[0] : null
                            , keyValuePair ? expectedTypes[1] : null);
                }
            }

            case 'V': {
                String type = readType();
                int length = readLength();

                Deserializer reader;
                reader = _serializerFactory.getObjectDeserializer(type);

                boolean valueType = expectedTypes != null && expectedTypes.length == 1;

                if (expectedClass != reader.getType() && expectedClass.isAssignableFrom(reader.getType()))
                    return reader.readList(this, length, valueType ? expectedTypes[0] : null);

                reader = _serializerFactory.getDeserializer(expectedClass);

                Object v = reader.readList(this, length, valueType ? expectedTypes[0] : null);

                return v;
            }

            case 'R': {
                int ref = parseInt();

                return _refs.get(ref);
            }

            case 'r': {
                String type = readType();
                String url = readString();

                return resolveRemote(type, url);
            }
        }

        _peek = tag;

        // hessian/332i vs hessian/3406
        //return readObject();

        Object value = _serializerFactory.getDeserializer(expectedClass).readObject(this);

        return value;
    }