Given a simple Java class like this:
class MyData {
public int a;
public int b;
public int c;
public int d;
}
And a MyData data[] that I need to pass into native code, is it better to do something like this:
for (MyData item : data) {
myNativeMethod(item.a,item.b,item.c,item.d);
}
Or is it better to myNativeMethod(data) and use GetArrayLength, GetObjectArrayElement and GetIntField?
In this case “better” is intentionally vague. Performance and maintainability are both concerns.
In your particular case it’s simpler to pass individual values as parameters. However, it will clutter your Java code once the object gets more complex.
Said that, I don’t see huge difference to prefer one way over another.