Reputation: 7204
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
.
Upvotes: 5
Views: 3182
Reputation: 16286
I know this question is old but...
To find a class of your array, use:
env->FindClass("[[Lmy/package/MyClass;")
Upvotes: 3
Reputation: 2862
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 :)
Upvotes: 1