Hi Alan,

Btw, I am wondering whether I need pass a variable to see if the returned char* is a copy or not, and basing on that to do the release.

For example,

jboolean isCopy;
const char *fname = JNU_GetStringPlatformChars(env, java_fname, &isCopy);
if (isCopy == JNI_TRUE)
   JNU_ReleaseStringPlatformChars(env, java_fname, fname);

But according to the definition of JNU_GetStringPlatformChars(), it seems always to set *isCopy to JNI_TRUE currently. Because nativeGetStringPlatformChars() does nothing now.

Thanks,

-Dan

On Wed 08 Jan 2014 09:56:40 AM PST, Dan Xu wrote:
Thank you, Alan. I will add this change into my fix and push it today.
Thanks!

-Dan


On 01/08/2014 01:24 AM, Alan Bateman wrote:
On 08/01/2014 00:50, Dan Xu wrote:
Hi All,

Thanks for your good review. I have dropped the change in
FileSystemPreferences.java , and created the new webrev which only
changes FileSystemPreferences.c. Please help review it. Thanks!

Webrev: http://cr.openjdk.java.net/~dxu/8028726/webrev.01/

When changing FileSystemPreferences.c, I noticed the code like
"JNU_GetStringPlatformChars(env, java_fname, JNI_FALSE)". Because
JNI_FALSE is passed into this function, I am wondering why our code
still release string by calling JNU_ReleaseStringPlatformChars(env,
java_fname, fname). Thanks!
This is the isCopy parameter to allow the function return whether it
has returned a copy or not. So the JNU_ReleaseStringPlatformChars is
needed. However the JNI_FALSE isn't right, it does happens to work
because JNI_FALSE is defined as 0, same as NULL. Do you mind changing
these to NULL as part of the change so that it's a bit more obvious?
(no need to publish a new webrev if there are no other changes).

Otherwise looks fine to me.

-Alan.

Reply via email to