    let {{ name }}_jarr = unsafe { jni::objects::JByteArray::from_raw(env, {{ name }}) };
{% if is_optional %}
    let {{ name }}: Option<Vec<u8>> = match env.get_array_length(&{{ name }}_jarr) {
        Ok(0) => None,
        Ok(_) => match env.convert_byte_array(&{{ name }}_jarr) {
            Ok(v) => Some(v),
            Err(e) => { throw_jni_error(env, &format!("{e}")); return {{ ret_null }}; }
        },
        Err(e) => { throw_jni_error(env, &format!("{e}")); return {{ ret_null }}; }
    };
{% else %}
    let {{ name }}: Vec<u8> = match env.convert_byte_array(&{{ name }}_jarr) {
        Ok(v) => v,
        Err(e) => { throw_jni_error(env, &format!("{e}")); return {{ ret_null }}; }
    };
{% endif %}
