Looks ok to me.

/Claes

On 2018-03-02 23:56, Roger Riggs wrote:
Please review a correction to the jni_util.c native code that does not compile on Solaris.
Declarations must precede assignments.

Issue: 8198970 jnu_util.c compilation error on Solaris <https://bugs.openjdk.java.net/browse/JDK-8198970>

diff --git a/src/java.base/share/native/libjava/jni_util.c b/src/java.base/share/native/libjava/jni_util.c
--- a/src/java.base/share/native/libjava/jni_util.c
+++ b/src/java.base/share/native/libjava/jni_util.c
@@ -803,10 +803,10 @@ InitializeEncoding(JNIEnv *env, const ch
             (strcmp(encname, "ISO-8859-1") == 0)) {
             fastEncoding = FAST_8859_1;
         } else if (strcmp(encname, "UTF-8") == 0) {
-            fastEncoding = FAST_UTF_8;
             jstring enc = (*env)->NewStringUTF(env, encname);
             if (enc == NULL)
                 return;
+            fastEncoding = FAST_UTF_8;
             jnuEncoding = (jstring)(*env)->NewGlobalRef(env, enc);
             (*env)->DeleteLocalRef(env, enc);
         } else if (strcmp(encname, "ISO646-US") == 0) {
@@ -818,10 +818,10 @@ InitializeEncoding(JNIEnv *env, const ch
             strcmp(encname, "utf-16le") == 0) {
             fastEncoding = FAST_CP1252;
         } else {
-            fastEncoding = NO_FAST_ENCODING;
             jstring enc = (*env)->NewStringUTF(env, encname);
             if (enc == NULL)
                 return;
+            fastEncoding = NO_FAST_ENCODING;
             jnuEncoding = (jstring)(*env)->NewGlobalRef(env, enc);
             (*env)->DeleteLocalRef(env, enc);
         }


Thanks, Roger



Reply via email to