Checking if Java object has array type in JNI

Let's say I have a MyClass class in Java, is there a way to check the JNI, what jobjectis it MyClass[][]?

My initial idea was to use env->IsInstanceOf(myobj, myArrayClass), but the challenge env->FindClass("[MyClass")chose NoClassDefFoundError.

+3
source share
2 answers

I know this question is old, but ...

To find the class of your array, use:

env->FindClass("[[Lmy/package/MyClass;")
+2
source

A bit rusty on JNI, but a few things:

Call FindClass()your full class name using "/" as a separator instead of periods. So for example, if your class "my.package.MyClass", you should callenv->FindClass("my/package/MyClass")

, env->GetObjectArrayElement(); , , . env->IsInstanceOf() . , JNI, :)

+1

Source: https://habr.com/ru/post/1738989/


All Articles