src/main/c/jnlua.c
static const char *readhandler(lua_State *L, void *ud, size_t *size) {
	Stream *stream;
	int read;

	stream = (Stream *)ud;
	read = (*thread_env)->CallIntMethod(thread_env, stream->stream, read_id, stream->byte_array);
	if ((*thread_env)->ExceptionCheck(thread_env)) {
		return NULL;
	}
	if (read == -1) {
		return NULL;
	}
	if (stream->bytes && stream->is_copy) {
		(*thread_env)->ReleaseByteArrayElements(thread_env, stream->byte_array, stream->bytes, JNI_ABORT);
		stream->bytes = NULL;
	}
	if (!stream->bytes) {
		stream->bytes = (*thread_env)->GetByteArrayElements(thread_env, stream->byte_array, &stream->is_copy);
		if (!stream->bytes) {
			(*thread_env)->ThrowNew(thread_env, ioexception_class, "JNI error: GetByteArrayElements() failed accessing IO buffer");
			return NULL;
		}
	}
	*size = (size_t)read;
	return (const char *)stream->bytes;
}
/* ---- Stream adapters ---- */
/* Lua reader for Java input streams. */
Stream adapters
Lua reader for Java input streams.
Stream adapters Lua reader for Java input streams .
static const char *readhandler(lua_State *L, void *ud, size_t *size) {
	Stream *stream;
	int read;
	stream = (Stream *)ud;
	read = (*thread_env)->CallIntMethod(thread_env, stream->stream, read_id, stream->byte_array);
	if ((*thread_env)->ExceptionCheck(thread_env)) {
		return NULL;
	}
	if (read == -1) {
		return NULL;
	}
	if (stream->bytes && stream->is_copy) {
		(*thread_env)->ReleaseByteArrayElements(thread_env, stream->byte_array, stream->bytes, JNI_ABORT);
		stream->bytes = NULL;
	}
	if (!stream->bytes) {
		stream->bytes = (*thread_env)->GetByteArrayElements(thread_env, stream->byte_array, &stream->is_copy);
		if (!stream->bytes) {
			(*thread_env)->ThrowNew(thread_env, ioexception_class, "JNI error: GetByteArrayElements() failed accessing IO buffer");
			return NULL;
		}
	}
	*size = (size_t)read;
	return (const char *)stream->bytes;
}
static const char * readhandler ( lua_State * L , void * ud , size_t * size ) { Stream * stream ; int read ; stream = ( Stream * ) ud ; read = ( * thread_env ) -> CallIntMethod ( thread_env , stream -> stream , read_id , stream -> byte_array ) ; if ( ( * thread_env ) -> ExceptionCheck ( thread_env ) ) { return NULL ; } if ( read == -1 ) { return NULL ; } if ( stream -> bytes && stream -> is_copy ) { ( * thread_env ) -> ReleaseByteArrayElements ( thread_env , stream -> byte_array , stream -> bytes , JNI_ABORT ) ; stream -> bytes = NULL ; } if ( ! stream -> bytes ) { stream -> bytes = ( * thread_env ) -> GetByteArrayElements ( thread_env , stream -> byte_array , & stream -> is_copy ) ; if ( ! stream -> bytes ) { ( * thread_env ) -> ThrowNew ( thread_env , ioexception_class , " " ) ; return NULL ; } } * size = ( size_t ) read ; return ( const char * ) stream -> bytes ; }
Stream adapters 
Lua reader for Java input streams.
Stream adapters Lua reader for Java input streams .