RFR: JDK-8028726 - (prefs) Check src/solaris/native/java/util/FileSystemPreferences.c for JNI pending exceptions
Alan Bateman
Alan.Bateman at oracle.com
Wed Jan 8 18:59:29 UTC 2014
On 08/01/2014 18:48, Dan Xu wrote:
> 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.
As things stand then JNU_GetStringPlatformChars always returned a copy.
If it were changed to conditionally return a copy then every usage would
need to specify isCopy and handle as you suggest. So it doesn't matter
if you specify NULL or &isCopy, both will work here.
-Alan
More information about the core-libs-dev
mailing list