Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>4 ideas to provide you:</p> <p>...</p> <p><em>jclass clazz = env->FindClass("com/path/to/the/class");</em></p> <p>Can you confirm the name is not "com/path/to/the/MyClass" where the classname is uppercase 1st character and obviously the name "class" is a reserved word. There is a slight discrepency between the use of the JNI C symbol name "Java_com_path_to_my_package_renderStuff" and the FindClass() lookup on "com/path/to/the/class"in your example. But since your stackoverflow is not a about UnsatisfiedLinkageError I can only guess your example provided is not consistent with itself.</p> <p>Using my example I would expect the JNI C symbol name to be "Java_com_path_to_the_MyClass_renderStuff" and the FindClass() lookup on "com/path/to/the/MyClass". The use of uppercase 1st letter of class and lowercase 1st letter of method name might be important for linkage purposes.</p> <p>...</p> <p>Are you sure the "jobj" being passed is the same type as the "com/path/to/the/class" you are looking up ? Maybe in your Java code you can wrap your native with:</p> <pre><code>public void renderStuff() { if((this instanceof com.path.to.the.MyClass) == false) throw new RuntimeException("Unexpected class expected: com.path.to.the.MyClass"); renderStuff_internal(); } private native void renderStuff_internal(); </code></pre> <p>Which will ensure that matter in Java code without causing a JVM crash. You would also need to adjust your C symbol name to append the "_1internal" onto the end making "Java_com_path_to_the_MyClass_renderStuff_1internal" (the extra "1" character is intended)</p> <p>...</p> <p>Maybe try belt and braces exception checking in between each statement you list about:</p> <pre><code>if(env-&gt;ExceptionCheck()) { env-&gt;ExceptionDescribe(); env-&gt;ExceptionClear(); } </code></pre> <p>This will pickup things like security violations when trying to do reflection when it might not be allowed.</p> <p>...</p> <pre><code> jclass cls = env-&gt;GetObjectClass(jobj); // instead of FindClass jmethodID mid = env-&gt;GetMethodID(cls, "showCar", "()V"); if(!mid) return; // whoops method does not exist env-&gt;CallVoidMethod(jobj, mid); </code></pre> <p>Another idea to remove the FindClass() call. This would work with any class that GetMethodID worked on, kind of like dyhamic typing / late-binding.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload