6.67. kink/javahost/JAVA_CHANNEL_OUTPUT

Provides `output` based on Java WritableByteChannel.

6.67.1. JAVA_CHANNEL_OUTPUT.new(Channel ...[$config={}])

`new` makes an `output` which wraps java.nio.channels.WritableByteChannel.

Config methods:

• C.buffer(...[Max_buf_size])

• C.close_method_handle(Close_mh): default = WritableByteChannel::close

Buffering

If C.buffer is called, the result output will perform userspace buffering. If `Max_buf_size` is given, the buffer size will not exceed `Max_buf_size` in byte length.

If C.buffer is not called, the result output will not perform userspace buffering.

Closing of the output

When `close` method of the result `output` is called, `Close_mh` is invoked with `Channel` as the argument.

If `Close_mh` throws an IOException during its invocation, `close` ends with an IO error.

Preconditions

`Channel` must be a `java` value whose objectReference is a WritableByteChannel. The objectReference must also be an instance of the parameter type of `Close_mh`.

`Max_buf_size` must be a positive int `num`.

`Close_mh` must be a `java` value of a MethodHandle, which takes a single parameter.

Invocation of `Close_mh` must throw an IOException when an IO error occurs.