class GridClientOptimizedMarshaller implements GridClientMarshaller {
    /** ID. */
    public static final byte ID = 1;

    /** Optimized marshaller. */
    protected final OptimizedMarshaller opMarsh;

    /**
     * Default constructor.
     */
    public GridClientOptimizedMarshaller() {
        opMarsh = new OptimizedMarshaller();

        opMarsh.setContext(new ClientMarshallerContext());
    }

    /**
     * Constructor.
     *
     * @param plugins Plugins.
     */
    public GridClientOptimizedMarshaller(@Nullable List<PluginProvider> plugins) {
        opMarsh = new OptimizedMarshaller();

        opMarsh.setContext(new ClientMarshallerContext(plugins));
    }

    /**
     * Constructs optimized marshaller with specific parameters.
     *
     * @param requireSer Require serializable flag.
     * @param poolSize Object streams pool size.
     * @throws IOException If an I/O error occurs while writing stream header.
     * @throws IgniteException If this marshaller is not supported on the current JVM.
     * @see OptimizedMarshaller
     */
    public GridClientOptimizedMarshaller(boolean requireSer, int poolSize) throws IOException {
        opMarsh = new OptimizedMarshaller();

        opMarsh.setContext(new ClientMarshallerContext());
        opMarsh.setRequireSerializable(requireSer);
        opMarsh.setPoolSize(poolSize);
    }

    /** {@inheritDoc} */
    @Override public ByteBuffer marshal(Object obj, int off) throws IOException {<FILL_FUNCTION_BODY>}

    /** {@inheritDoc} */
    @Override public <T> T unmarshal(byte[] bytes) throws IOException {
        try {
            return U.unmarshal(opMarsh, bytes, null);
        }
        catch (IgniteCheckedException e) {
            throw new IOException(e);
        }
    }

    /**
     */
    private static class ClientMarshallerContext extends MarshallerContextImpl {
        /** */
        public ClientMarshallerContext() {
            super(null, null);
        }

        /**
         * @param plugins Plugins.
         */
        public ClientMarshallerContext(@Nullable List<PluginProvider> plugins) {
            super(plugins, null);
        }
    }
}

        try {
            if (!(obj instanceof GridClientMessage))
                throw new IOException("Message serialization of given type is not supported: " +
                    obj.getClass().getName());

            byte[] bytes = U.marshal(opMarsh, obj);

            ByteBuffer buf = ByteBuffer.allocate(off + bytes.length);

            buf.position(off);

            buf.put(bytes);

            buf.flip();

            return buf;
        }
        catch (IgniteCheckedException e) {
            throw new IOException(e);
        }
    
<no_super_class>