Try catch in JNI

562 views
Skip to first unread message

B.Arunkumar

unread,
Apr 11, 2012, 1:42:39 AM4/11/12
to android-ndk
Hi,

I would like to know if it is possible to incude try catch and
handle exceptions in JNI?

Thank you,
B.Arunkumar

Mārtiņš Možeiko

unread,
Apr 11, 2012, 2:15:35 PM4/11/12
to andro...@googlegroups.com
Yes, it is.
Read about how to use exceptions in JNI here:
http://java.sun.com/docs/books/jni/html/exceptions.html#11202

--
Mārtiņš Možeiko

> --
> You received this message because you are subscribed to the Google Groups "android-ndk" group.
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
>

B.Arunkumar

unread,
May 4, 2012, 6:04:17 AM5/4/12
to android-ndk
Hi,

We have created an FFMPEG wrapper class called VideoDecoder.cpp
which has this native method:-

void VideoDecoder::decodeFrame(uint8_t* frameData, size_t length)
{
int res = avcodec_decode_video2(codecCtx,
srcFrame,&frameFinished, &packet);
}

Now our application crashes at this line sometimes. Is there any way
of catching this exception and prevent the application from crashing?
It also seems like the link you have given does not take of these
situations. (Quote "We will focus on errors that occur as the result
of issuing JNI function calls, not arbitrary errors that happen in
native code")

Thank you,
B.Arunkumar

On Apr 11, 11:15 pm, Mārtiņš Možeiko <martins.moze...@gmail.com>
wrote:
> Yes, it is.
> Read about how to use exceptions inJNIhere:http://java.sun.com/docs/books/jni/html/exceptions.html#11202
Reply all
Reply to author
Forward
0 new messages