[9] RFR: 8170465, 8170466: JNI exception pending in jni_util.c:190
David Holmes
david.holmes at oracle.com
Wed Dec 7 00:53:33 UTC 2016
Hi Naoto,
On 7/12/2016 10:02 AM, Naoto Sato wrote:
> Hello,
>
> Please review the proposed fix to the following issues:
>
> https://bugs.openjdk.java.net/browse/JDK-8170465
> https://bugs.openjdk.java.net/browse/JDK-8170466
>
> The proposed fix is located at:
>
> http://cr.openjdk.java.net/~naoto/8170465.8170466/webrev.00/
>
> These two JNI calls (NewStringUTF() and JNU_CallMethodByName()) in
> src/java.base/share/native/libjava/jni_util.c can throw an exception.
> Those possible exceptions need to be properly checked.
JNU_CHECK_EXCEPTION will do a return from the method in which it is
placed, so you need to be careful to ensure you do all needed cleanup
before that eg:
203 JNU_CHECK_EXCEPTION(env);
204 free(str1);
needs to be reversed else we won't free str1. Similarly:
210 JNU_CHECK_EXCEPTION(env);
211 (*env)->DeleteLocalRef(env, s2);
needs to be reversed so we don't leak the local ref. (It is safe to call
DeleteLocalRef with an exception pending.)
Thanks,
David
> Naoto
More information about the core-libs-dev
mailing list