JNI, cast between jobect and jthrowable
I need raise an exception from C++ code. Raised exception must contain text and code of error. So common form:
ThrowNew(jclass clazz, const char *msg)
is not applicable. That is why I want create my own instance of java class:
public class MyException extends Exception
开发者_开发问答that contains one more property for code. But JNI interface has only declaration for
Throw(jthrowable obj)
Is it correct to cast instance of MyException to jthrowable ?
For the JVM jthrowable is an instance of java.lang.Throwable so if you instantiate the exception in your JNI code and cast it, it should work.
精彩评论