开发者

JNI, cast between jobect and jthrowable

开发者 https://www.devze.com 2022-12-23 06:03 出处:网络
I need raise an exception from C++ code. Raised exception must contain text and code of error. So common form:

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

精彩评论

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