Say I have a MyClass class in Java, is there a way to check in JNI that a jobject
is a MyClass[][]
?
My initial idea was to use env->IsInstanceOf(myobj, myArrayClass)
, but calling env->FindClass("[MyClass")
throws a NoClassDefFoundError
.
Say I have a MyClass class in Java, is there a way to check in JNI that a jobject
is a MyClass[][]
?
My initial idea was to use env->IsInstanceOf(myobj, myArrayClass)
, but calling env->FindClass("[MyClass")
throws a NoClassDefFoundError
.
A little rusty on JNI, but a couple of things:
Call FindClass()
on your fully qualified classname, using a "/" as a separator instead of dots. So, for instance if your class is "my.package.MyClass"
, you would call env->FindClass("my/package/MyClass")
Since you have a two-dimensional array of your object type, you need to call env->GetObjectArrayElement()
twice; once to get a row and another time to get a distinct element. Then you can call env->IsInstanceOf()
on that element. Make sure you look up the correct signatures for these JNI calls, I've left them as an exercise for the reader :)