static jintArray android_mtp_MtpDevice_get_object_handles(JNIEnv *env, jobject thiz, jint storageID, jint format, jint objectID) { MtpDevice* device = get_device_from_object(env, thiz); if (!device) return NULL; MtpObjectHandleList* handles = device->getObjectHandles(storageID, format, objectID); if (!handles) return NULL; int length = handles->size(); jintArray array = env->NewIntArray(length); // FIXME is this cast safe? env->SetIntArrayRegion(array, 0, length, (const jint *)handles->array()); delete handles; return array; }