diff --git a/java/src/main/native/OrtJniUtil.c b/java/src/main/native/OrtJniUtil.c index 96dd5dfacf429..7b26291581395 100644 --- a/java/src/main/native/OrtJniUtil.c +++ b/java/src/main/native/OrtJniUtil.c @@ -373,7 +373,7 @@ jobject convertToTensorInfo(JNIEnv *jniEnv, const OrtApi * api, const OrtTensorT jobjectArray names = (*jniEnv)->NewObjectArray(jniEnv, safecast_size_t_to_jsize(numDim), stringClazz, NULL); for (size_t i = 0; i < numDim; i++) { jobject javaName = (*jniEnv)->NewStringUTF(jniEnv, dimensionNames[i]); - (*jniEnv)->SetObjectArrayElement(jniEnv, names, i, safecast_size_t_to_jsize(javaName)); + (*jniEnv)->SetObjectArrayElement(jniEnv, names, safecast_size_t_to_jsize(i), javaName); } free(dimensionNames);