How to create an object with JNI?

Since Point is an inner class, the way to get it would be

jclass cls = (*env)->FindClass(env, "com/example/ndktest/NDKTest$Point");

The $ convention for inner classes is not really clearly documented in the authoritative specs, but is entrenched in so much working code that it’s unlikely to change. Still, it would feel somewhat more robust if you restricted your JNI code to work with top-level classes.

You want a constructor that takes two ints as arguments. The signature for that is (II)V, so:

constructor = (*env)->GetMethodID(env, cls, "<init>", "(II)V");

Next time, include some error handling in your code, such that you’ll have a clue which part of it doesn’t work!

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)