开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜