[9] RFR: 8170465, 8170466: JNI exception pending in jni_util.c:190

Naoto Sato naoto.sato at oracle.com
Wed Dec 7 01:04:42 UTC 2016


Thanks, David. The fix is modified accordingly:

http://cr.openjdk.java.net/~naoto/8170465.8170466/webrev.01/

Naoto

On 12/6/16 4:53 PM, David Holmes wrote:
> 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