jobjectArray wrapBosDevCapabilityDescriptors(JNIEnv *env, int count,
    struct libusb_bos_dev_capability_descriptor **descriptors)
{
    int i;

    jobjectArray array = (jobjectArray) (*env)->NewObjectArray(env,
        count, (*env)->FindClass(env, PACKAGE_DIR"/BosDevCapabilityDescriptor"),
        NULL);
    for (i = 0; i < count; i++)
        (*env)->SetObjectArrayElement(env, array, i,
            wrapBosDevCapabilityDescriptor(env, descriptors[i]));
    return array;
}
jobjectArray wrapBosDevCapabilityDescriptors(JNIEnv *env, int count,
    struct libusb_bos_dev_capability_descriptor * const *descriptors)
{
    jobjectArray array = (jobjectArray) (*env)->NewObjectArray(env,
        count, (*env)->FindClass(env, CLASS_PATH("BosDevCapabilityDescriptor")),
        NULL);

    for (int i = 0; i < count; i++)
        (*env)->SetObjectArrayElement(env, array, i,
            wrapBosDevCapabilityDescriptor(env, descriptors[i]));

    return array;
}