Java: How are errors customarily handled for native code in jni calls? -


I've google'd around a while, and in fact did not find a good answer for my question: Is Java information in the customary way of returning Java from the original Java code?

I usually take just one design and go with it, but this code is called every 5 milliseconds (approx), so I thought if there is a conservative 'clean / efficient' way. Do it

The way I see it, it has four clear options:

  1. On each call, create an "Error Return" object in Java and pass it If this is a problem through JNI, the original code fills in this object in the error description, and the Java code checks it on the return. Since errors are not normal conditions, so many objects are prepared to clean GC, and 99.99% of them are unnecessary.

  2. Create something similar to # 1, single "error returns" objects in Java classes that pass each method call over and over is. Look at the error in the Java code on each return for errors, it looks tight for me, but maybe this is the right choice?

  3. Create an object in the native code that describes the error when applicable, and pass it back after returning the value in Java to Java, return for zero Check it out. It seems less useless than # 1, but it seems a little weird.

  4. Just create an integer return value on the jni method, and pass an int related to "exit" the value of the native code in the Java map, all possible native exits Tell the status, compare the return value to '0', and see the error in this map if necessary. It appears to be more efficient than others, but seems more clumsy, because no change in the original code To someone You will need to go back and update the "error table".

I feel as if I am not clear ... is there a guru

Thank you!

throw a Java exception:?


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -