private void sendObject(Object object, List<ForkResource> resources)
            throws IOException, TikaException {
        int n = resources.size();
        if (object instanceof InputStream) {
            resources.add(new InputStreamResource((InputStream) object));
            object = new InputStreamProxy(n);
        } else if (object instanceof RecursiveParserWrapperHandler) {
            resources.add(new RecursiveMetadataContentHandlerResource(
                    (RecursiveParserWrapperHandler) object));
            object = new RecursiveMetadataContentHandlerProxy(n,
                    ((RecursiveParserWrapperHandler) object).getContentHandlerFactory());
        } else if (object instanceof ContentHandler &&
                !(object instanceof AbstractRecursiveParserWrapperHandler)) {
            resources.add(new ContentHandlerResource((ContentHandler) object));
            object = new ContentHandlerProxy(n);
        } else if (object instanceof ClassLoader) {
            resources.add(new ClassLoaderResource((ClassLoader) object));
            object = new ClassLoaderProxy(n);
        }

        try {
            ForkObjectInputStream.sendObject(object, output);
        } catch (NotSerializableException nse) {
            // Build a more friendly error message for this
            throw new TikaException("Unable to serialize " + object.getClass().getSimpleName() +
                    " to pass to the Forked Parser", nse);
        }

        waitForResponse(resources);
    }
Serializes the object first into an in-memory buffer and then
writes it to the output stream with a preceding size integer.

@param object    object to be serialized
@param resources list of fork resources, used when adding proxies
@throws IOException if the object could not be serialized
tika-core/src/main/java/org/apache/tika/fork/ForkClient.java