8198899: Compilation errors in java.prefs with VS 2017
authorbpb
Thu, 08 Mar 2018 08:17:26 -0800
changeset 49154 28729cf7e4bc
parent 49153 5447851ff0f6
child 49155 7cd937277d5e
8198899: Compilation errors in java.prefs with VS 2017 Summary: Change Java level representation of HKEY from int to long Reviewed-by: alanb, rriggs, psandoz
src/java.prefs/windows/classes/java/util/prefs/WindowsPreferences.java
src/java.prefs/windows/native/libprefs/WindowsPreferences.c
--- a/src/java.prefs/windows/classes/java/util/prefs/WindowsPreferences.java	Thu Mar 08 11:21:57 2018 +0900
+++ b/src/java.prefs/windows/classes/java/util/prefs/WindowsPreferences.java	Thu Mar 08 08:17:26 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -172,22 +172,22 @@
     /**
      * Java wrapper for Windows registry API RegOpenKey()
      */
-    private static native int[] WindowsRegOpenKey(int hKey, byte[] subKey,
-                                                  int securityMask);
+    private static native long[] WindowsRegOpenKey(long hKey, byte[] subKey,
+                                                   int securityMask);
     /**
      * Retries RegOpenKey() MAX_ATTEMPTS times before giving up.
      */
-    private static int[] WindowsRegOpenKey1(int hKey, byte[] subKey,
-                                            int securityMask) {
-        int[] result = WindowsRegOpenKey(hKey, subKey, securityMask);
+    private static long[] WindowsRegOpenKey1(long hKey, byte[] subKey,
+                                             int securityMask) {
+        long[] result = WindowsRegOpenKey(hKey, subKey, securityMask);
         if (result[ERROR_CODE] == ERROR_SUCCESS) {
             return result;
         } else if (result[ERROR_CODE] == ERROR_FILE_NOT_FOUND) {
             logger().warning("Trying to recreate Windows registry node " +
             byteArrayToString(subKey) + " at root 0x" +
-            Integer.toHexString(hKey) + ".");
+            Long.toHexString(hKey) + ".");
             // Try recreation
-            int handle = WindowsRegCreateKeyEx(hKey, subKey)[NATIVE_HANDLE];
+            long handle = WindowsRegCreateKeyEx(hKey, subKey)[NATIVE_HANDLE];
             WindowsRegCloseKey(handle);
             return WindowsRegOpenKey(hKey, subKey, securityMask);
         } else if (result[ERROR_CODE] != ERROR_ACCESS_DENIED) {
@@ -211,18 +211,18 @@
      /**
      * Java wrapper for Windows registry API RegCloseKey()
      */
-    private static native int WindowsRegCloseKey(int hKey);
+    private static native int WindowsRegCloseKey(long hKey);
 
     /**
      * Java wrapper for Windows registry API RegCreateKeyEx()
      */
-    private static native int[] WindowsRegCreateKeyEx(int hKey, byte[] subKey);
+    private static native long[] WindowsRegCreateKeyEx(long hKey, byte[] subKey);
 
     /**
      * Retries RegCreateKeyEx() MAX_ATTEMPTS times before giving up.
      */
-    private static int[] WindowsRegCreateKeyEx1(int hKey, byte[] subKey) {
-        int[] result = WindowsRegCreateKeyEx(hKey, subKey);
+    private static long[] WindowsRegCreateKeyEx1(long hKey, byte[] subKey) {
+        long[] result = WindowsRegCreateKeyEx(hKey, subKey);
         if (result[ERROR_CODE] == ERROR_SUCCESS) {
             return result;
         } else {
@@ -245,17 +245,17 @@
     /**
      * Java wrapper for Windows registry API RegDeleteKey()
      */
-    private static native int WindowsRegDeleteKey(int hKey, byte[] subKey);
+    private static native int WindowsRegDeleteKey(long hKey, byte[] subKey);
 
     /**
      * Java wrapper for Windows registry API RegFlushKey()
      */
-    private static native int WindowsRegFlushKey(int hKey);
+    private static native int WindowsRegFlushKey(long hKey);
 
     /**
      * Retries RegFlushKey() MAX_ATTEMPTS times before giving up.
      */
-    private static int WindowsRegFlushKey1(int hKey) {
+    private static int WindowsRegFlushKey1(long hKey) {
         int result = WindowsRegFlushKey(hKey);
         if (result == ERROR_SUCCESS) {
             return result;
@@ -280,17 +280,17 @@
     /**
      * Java wrapper for Windows registry API RegQueryValueEx()
      */
-    private static native byte[] WindowsRegQueryValueEx(int hKey,
+    private static native byte[] WindowsRegQueryValueEx(long hKey,
                                                         byte[] valueName);
     /**
      * Java wrapper for Windows registry API RegSetValueEx()
      */
-    private static native int WindowsRegSetValueEx(int hKey, byte[] valueName,
+    private static native int WindowsRegSetValueEx(long hKey, byte[] valueName,
                                                    byte[] value);
     /**
      * Retries RegSetValueEx() MAX_ATTEMPTS times before giving up.
      */
-    private static int WindowsRegSetValueEx1(int hKey, byte[] valueName,
+    private static int WindowsRegSetValueEx1(long hKey, byte[] valueName,
                                              byte[] value) {
         int result = WindowsRegSetValueEx(hKey, valueName, value);
         if (result == ERROR_SUCCESS) {
@@ -316,18 +316,18 @@
     /**
      * Java wrapper for Windows registry API RegDeleteValue()
      */
-    private static native int WindowsRegDeleteValue(int hKey, byte[] valueName);
+    private static native int WindowsRegDeleteValue(long hKey, byte[] valueName);
 
     /**
      * Java wrapper for Windows registry API RegQueryInfoKey()
      */
-    private static native int[] WindowsRegQueryInfoKey(int hKey);
+    private static native long[] WindowsRegQueryInfoKey(long hKey);
 
     /**
      * Retries RegQueryInfoKey() MAX_ATTEMPTS times before giving up.
      */
-    private static int[] WindowsRegQueryInfoKey1(int hKey) {
-        int[] result = WindowsRegQueryInfoKey(hKey);
+    private static long[] WindowsRegQueryInfoKey1(long hKey) {
+        long[] result = WindowsRegQueryInfoKey(hKey);
         if (result[ERROR_CODE] == ERROR_SUCCESS) {
             return result;
         } else {
@@ -351,13 +351,13 @@
     /**
      * Java wrapper for Windows registry API RegEnumKeyEx()
      */
-    private static native byte[] WindowsRegEnumKeyEx(int hKey, int subKeyIndex,
+    private static native byte[] WindowsRegEnumKeyEx(long hKey, int subKeyIndex,
                                                      int maxKeyLength);
 
     /**
      * Retries RegEnumKeyEx() MAX_ATTEMPTS times before giving up.
      */
-    private static byte[] WindowsRegEnumKeyEx1(int hKey, int subKeyIndex,
+    private static byte[] WindowsRegEnumKeyEx1(long hKey, int subKeyIndex,
                                                int maxKeyLength) {
         byte[] result = WindowsRegEnumKeyEx(hKey, subKeyIndex, maxKeyLength);
         if (result != null) {
@@ -383,12 +383,12 @@
     /**
      * Java wrapper for Windows registry API RegEnumValue()
      */
-    private static native byte[] WindowsRegEnumValue(int hKey, int valueIndex,
+    private static native byte[] WindowsRegEnumValue(long hKey, int valueIndex,
                                                      int maxValueNameLength);
     /**
      * Retries RegEnumValueEx() MAX_ATTEMPTS times before giving up.
      */
-    private static byte[] WindowsRegEnumValue1(int hKey, int valueIndex,
+    private static byte[] WindowsRegEnumValue1(long hKey, int valueIndex,
                                                int maxValueNameLength) {
         byte[] result = WindowsRegEnumValue(hKey, valueIndex,
                                             maxValueNameLength);
@@ -421,18 +421,18 @@
      */
     private WindowsPreferences(WindowsPreferences parent, String name) {
         super(parent, name);
-        int parentNativeHandle = parent.openKey(KEY_CREATE_SUB_KEY, KEY_READ);
+        long parentNativeHandle = parent.openKey(KEY_CREATE_SUB_KEY, KEY_READ);
         if (parentNativeHandle == NULL_NATIVE_HANDLE) {
             // if here, openKey failed and logged
             isBackingStoreAvailable = false;
             return;
         }
-        int[] result =
+        long[] result =
                WindowsRegCreateKeyEx1(parentNativeHandle, toWindowsName(name));
         if (result[ERROR_CODE] != ERROR_SUCCESS) {
             logger().warning("Could not create windows registry node " +
                     byteArrayToString(windowsAbsolutePath()) +
-                    " at root 0x" + Integer.toHexString(rootNativeHandle()) +
+                    " at root 0x" + Long.toHexString(rootNativeHandle()) +
                     ". Windows RegCreateKeyEx(...) returned error code " +
                     result[ERROR_CODE] + ".");
             isBackingStoreAvailable = false;
@@ -451,14 +451,14 @@
      * @param rootNativeHandle Native handle to one of Windows top level keys.
      * @param rootDirectory Path to root directory, as a byte-encoded string.
      */
-    private  WindowsPreferences(int rootNativeHandle, byte[] rootDirectory) {
+    private  WindowsPreferences(long rootNativeHandle, byte[] rootDirectory) {
         super(null, "");
-        int[] result =
+        long[] result =
                 WindowsRegCreateKeyEx1(rootNativeHandle, rootDirectory);
         if (result[ERROR_CODE] != ERROR_SUCCESS) {
             logger().warning("Could not open/create prefs root node " +
                     byteArrayToString(windowsAbsolutePath()) +
-                    " at root 0x" + Integer.toHexString(rootNativeHandle()) +
+                    " at root 0x" + Long.toHexString(rootNativeHandle()) +
                     ". Windows RegCreateKeyEx(...) returned error code " +
                     result[ERROR_CODE] + ".");
             isBackingStoreAvailable = false;
@@ -497,7 +497,7 @@
      * @see #openKey(int, byte[], int)
      * @see #closeKey(int)
      */
-    private int openKey(int securityMask) {
+    private long openKey(int securityMask) {
         return openKey(securityMask, securityMask);
     }
 
@@ -511,7 +511,7 @@
      * @see #openKey(int, byte[], int)
      * @see #closeKey(int)
      */
-    private int openKey(int mask1, int mask2) {
+    private long openKey(int mask1, int mask2) {
         return openKey(windowsAbsolutePath(), mask1,  mask2);
     }
 
@@ -527,12 +527,12 @@
      * @see #openKey(int, byte[],int)
      * @see #closeKey(int)
      */
-    private int openKey(byte[] windowsAbsolutePath, int mask1, int mask2) {
+    private long openKey(byte[] windowsAbsolutePath, int mask1, int mask2) {
         /*  Check if key's path is short enough be opened at once
             otherwise use a path-splitting procedure */
         if (windowsAbsolutePath.length <= MAX_WINDOWS_PATH_LENGTH + 1) {
-            int[] result = WindowsRegOpenKey1(rootNativeHandle(),
-                                              windowsAbsolutePath, mask1);
+            long[] result = WindowsRegOpenKey1(rootNativeHandle(),
+                                               windowsAbsolutePath, mask1);
             if (result[ERROR_CODE] == ERROR_ACCESS_DENIED && mask2 != mask1)
                 result = WindowsRegOpenKey1(rootNativeHandle(),
                                             windowsAbsolutePath, mask2);
@@ -541,7 +541,7 @@
                 logger().warning("Could not open windows registry node " +
                         byteArrayToString(windowsAbsolutePath()) +
                         " at root 0x" +
-                        Integer.toHexString(rootNativeHandle()) +
+                        Long.toHexString(rootNativeHandle()) +
                         ". Windows RegOpenKey(...) returned error code " +
                         result[ERROR_CODE] + ".");
                 result[NATIVE_HANDLE] = NULL_NATIVE_HANDLE;
@@ -550,7 +550,7 @@
                             "Could not open windows registry node " +
                             byteArrayToString(windowsAbsolutePath()) +
                             " at root 0x" +
-                            Integer.toHexString(rootNativeHandle()) +
+                            Long.toHexString(rootNativeHandle()) +
                             ": Access denied");
                 }
             }
@@ -573,12 +573,12 @@
      * @see #openKey(byte[],int)
      * @see #closeKey(int)
      */
-    private int openKey(int nativeHandle, byte[] windowsRelativePath,
-                        int mask1, int mask2) {
+    private long openKey(long nativeHandle, byte[] windowsRelativePath,
+                         int mask1, int mask2) {
     /* If the path is short enough open at once. Otherwise split the path */
         if (windowsRelativePath.length <= MAX_WINDOWS_PATH_LENGTH + 1 ) {
-            int[] result = WindowsRegOpenKey1(nativeHandle,
-                                              windowsRelativePath, mask1);
+            long[] result = WindowsRegOpenKey1(nativeHandle,
+                                               windowsRelativePath, mask1);
             if (result[ERROR_CODE] == ERROR_ACCESS_DENIED && mask2 != mask1)
                 result = WindowsRegOpenKey1(nativeHandle,
                                             windowsRelativePath, mask2);
@@ -586,7 +586,7 @@
             if (result[ERROR_CODE] != ERROR_SUCCESS) {
                 logger().warning("Could not open windows registry node " +
                         byteArrayToString(windowsAbsolutePath()) +
-                        " at root 0x" + Integer.toHexString(nativeHandle) +
+                        " at root 0x" + Long.toHexString(nativeHandle) +
                         ". Windows RegOpenKey(...) returned error code " +
                         result[ERROR_CODE] + ".");
                 result[NATIVE_HANDLE] = NULL_NATIVE_HANDLE;
@@ -610,13 +610,13 @@
                                       separatorPosition - 1];
             System.arraycopy(windowsRelativePath, separatorPosition+1,
                              nextRelativePath, 0, nextRelativePath.length);
-            int nextNativeHandle = openKey(nativeHandle, nextRelativeRoot,
+            long nextNativeHandle = openKey(nativeHandle, nextRelativeRoot,
                                            mask1, mask2);
             if (nextNativeHandle == NULL_NATIVE_HANDLE) {
                 return NULL_NATIVE_HANDLE;
             }
-            int result = openKey(nextNativeHandle, nextRelativePath,
-                                 mask1,mask2);
+            long result = openKey(nextNativeHandle, nextRelativePath,
+                                  mask1,mask2);
             closeKey(nextNativeHandle);
             return result;
         }
@@ -630,13 +630,13 @@
      * @see #openKey(byte[],int)
      * @see #openKey(int, byte[],int)
     */
-    private void closeKey(int nativeHandle) {
+    private void closeKey(long nativeHandle) {
         int result = WindowsRegCloseKey(nativeHandle);
         if (result != ERROR_SUCCESS) {
             logger().warning("Could not close windows registry node " +
                     byteArrayToString(windowsAbsolutePath()) +
                     " at root 0x" +
-                    Integer.toHexString(rootNativeHandle()) +
+                    Long.toHexString(rootNativeHandle()) +
                     ". Windows RegCloseKey(...) returned error code " +
                     result + ".");
         }
@@ -649,7 +649,7 @@
      * @see #getSpi(String)
      */
     protected void putSpi(String javaName, String value) {
-        int nativeHandle = openKey(KEY_SET_VALUE);
+        long nativeHandle = openKey(KEY_SET_VALUE);
         if (nativeHandle == NULL_NATIVE_HANDLE) {
             isBackingStoreAvailable = false;
             return;
@@ -662,7 +662,7 @@
                     " at Windows registry node " +
                     byteArrayToString(windowsAbsolutePath()) +
                     " at root 0x" +
-                    Integer.toHexString(rootNativeHandle()) +
+                    Long.toHexString(rootNativeHandle()) +
                     ". Windows RegSetValueEx(...) returned error code " +
                     result + ".");
             isBackingStoreAvailable = false;
@@ -677,7 +677,7 @@
      * @see #putSpi(String, String)
      */
     protected String getSpi(String javaName) {
-        int nativeHandle = openKey(KEY_QUERY_VALUE);
+        long nativeHandle = openKey(KEY_QUERY_VALUE);
         if (nativeHandle == NULL_NATIVE_HANDLE) {
             return null;
         }
@@ -699,7 +699,7 @@
      * been deleted.
      */
     protected void removeSpi(String key) {
-        int nativeHandle = openKey(KEY_SET_VALUE);
+        long nativeHandle = openKey(KEY_SET_VALUE);
         if (nativeHandle == NULL_NATIVE_HANDLE) {
         return;
         }
@@ -709,7 +709,7 @@
             logger().warning("Could not delete windows registry value " +
                     byteArrayToString(windowsAbsolutePath()) + "\\" +
                     toWindowsName(key) + " at root 0x" +
-                    Integer.toHexString(rootNativeHandle()) +
+                    Long.toHexString(rootNativeHandle()) +
                     ". Windows RegDeleteValue(...) returned error code " +
                     result + ".");
             isBackingStoreAvailable = false;
@@ -725,27 +725,27 @@
      */
     protected String[] keysSpi() throws BackingStoreException{
         // Find out the number of values
-        int nativeHandle = openKey(KEY_QUERY_VALUE);
+        long nativeHandle = openKey(KEY_QUERY_VALUE);
         if (nativeHandle == NULL_NATIVE_HANDLE) {
             throw new BackingStoreException(
                     "Could not open windows registry node " +
                     byteArrayToString(windowsAbsolutePath()) +
                     " at root 0x" +
-                    Integer.toHexString(rootNativeHandle()) + ".");
+                    Long.toHexString(rootNativeHandle()) + ".");
         }
-        int[] result =  WindowsRegQueryInfoKey1(nativeHandle);
+        long[] result =  WindowsRegQueryInfoKey1(nativeHandle);
         if (result[ERROR_CODE] != ERROR_SUCCESS) {
             String info = "Could not query windows registry node " +
                     byteArrayToString(windowsAbsolutePath()) +
                     " at root 0x" +
-                    Integer.toHexString(rootNativeHandle()) +
+                    Long.toHexString(rootNativeHandle()) +
                     ". Windows RegQueryInfoKeyEx(...) returned error code " +
                     result[ERROR_CODE] + ".";
             logger().warning(info);
             throw new BackingStoreException(info);
         }
-        int maxValueNameLength = result[MAX_VALUE_NAME_LENGTH];
-        int valuesNumber = result[VALUES_NUMBER];
+        int maxValueNameLength = (int)result[MAX_VALUE_NAME_LENGTH];
+        int valuesNumber = (int)result[VALUES_NUMBER];
         if (valuesNumber == 0) {
             closeKey(nativeHandle);
             return new String[0];
@@ -759,7 +759,7 @@
                 String info =
                     "Could not enumerate value #" + i + "  of windows node " +
                     byteArrayToString(windowsAbsolutePath()) + " at root 0x" +
-                    Integer.toHexString(rootNativeHandle()) + ".";
+                    Long.toHexString(rootNativeHandle()) + ".";
                 logger().warning(info);
                 throw new BackingStoreException(info);
             }
@@ -777,27 +777,27 @@
      */
     protected String[] childrenNamesSpi() throws BackingStoreException {
         // Open key
-        int nativeHandle = openKey(KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE);
+        long nativeHandle = openKey(KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE);
         if (nativeHandle == NULL_NATIVE_HANDLE) {
             throw new BackingStoreException(
                     "Could not open windows registry node " +
                     byteArrayToString(windowsAbsolutePath()) +
                     " at root 0x" +
-                    Integer.toHexString(rootNativeHandle()) + ".");
+                    Long.toHexString(rootNativeHandle()) + ".");
         }
         // Get number of children
-        int[] result =  WindowsRegQueryInfoKey1(nativeHandle);
+        long[] result =  WindowsRegQueryInfoKey1(nativeHandle);
         if (result[ERROR_CODE] != ERROR_SUCCESS) {
             String info = "Could not query windows registry node " +
                     byteArrayToString(windowsAbsolutePath()) +
-                    " at root 0x" + Integer.toHexString(rootNativeHandle()) +
+                    " at root 0x" + Long.toHexString(rootNativeHandle()) +
                     ". Windows RegQueryInfoKeyEx(...) returned error code " +
                     result[ERROR_CODE] + ".";
             logger().warning(info);
             throw new BackingStoreException(info);
         }
-        int maxKeyLength = result[MAX_KEY_LENGTH];
-        int subKeysNumber = result[SUBKEYS_NUMBER];
+        int maxKeyLength = (int)result[MAX_KEY_LENGTH];
+        int subKeysNumber = (int)result[SUBKEYS_NUMBER];
         if (subKeysNumber == 0) {
             closeKey(nativeHandle);
             return new String[0];
@@ -812,7 +812,7 @@
                 String info =
                     "Could not enumerate key #" + i + "  of windows node " +
                     byteArrayToString(windowsAbsolutePath()) + " at root 0x" +
-                    Integer.toHexString(rootNativeHandle()) + ". ";
+                    Long.toHexString(rootNativeHandle()) + ". ";
                 logger().warning(info);
                 throw new BackingStoreException(info);
             }
@@ -839,20 +839,20 @@
             throw new BackingStoreException(
                     "flush(): Backing store not available.");
         }
-        int nativeHandle = openKey(KEY_READ);
+        long nativeHandle = openKey(KEY_READ);
         if (nativeHandle == NULL_NATIVE_HANDLE) {
             throw new BackingStoreException(
                     "Could not open windows registry node " +
                     byteArrayToString(windowsAbsolutePath()) +
                     " at root 0x" +
-                    Integer.toHexString(rootNativeHandle()) + ".");
+                    Long.toHexString(rootNativeHandle()) + ".");
         }
         int result = WindowsRegFlushKey1(nativeHandle);
         if (result != ERROR_SUCCESS) {
             String info = "Could not flush windows registry node " +
                     byteArrayToString(windowsAbsolutePath()) +
                     " at root 0x" +
-                    Integer.toHexString(rootNativeHandle()) +
+                    Long.toHexString(rootNativeHandle()) +
                     ". Windows RegFlushKey(...) returned error code " +
                     result + ".";
             logger().warning(info);
@@ -891,21 +891,21 @@
      * is not available.
      */
     public void removeNodeSpi() throws BackingStoreException {
-        int parentNativeHandle =
+        long parentNativeHandle =
                 ((WindowsPreferences)parent()).openKey(DELETE);
         if (parentNativeHandle == NULL_NATIVE_HANDLE) {
             throw new BackingStoreException(
                     "Could not open parent windows registry node of " +
                     byteArrayToString(windowsAbsolutePath()) +
                     " at root 0x" +
-                    Integer.toHexString(rootNativeHandle()) + ".");
+                    Long.toHexString(rootNativeHandle()) + ".");
         }
         int result =
                 WindowsRegDeleteKey(parentNativeHandle, toWindowsName(name()));
         if (result != ERROR_SUCCESS) {
             String info = "Could not delete windows registry node " +
                     byteArrayToString(windowsAbsolutePath()) +
-                    " at root 0x" + Integer.toHexString(rootNativeHandle()) +
+                    " at root 0x" + Long.toHexString(rootNativeHandle()) +
                     ". Windows RegDeleteKeyEx(...) returned error code " +
                     result + ".";
             logger().warning(info);
@@ -1089,7 +1089,7 @@
             if ((ch < 0x0020) || (ch > 0x007f)){
                 // write \udddd
                 windowsName.append("/u");
-                String hex = Integer.toHexString(javaName.charAt(i));
+                String hex = Long.toHexString(javaName.charAt(i));
                 StringBuilder hex4 = new StringBuilder(hex);
                 hex4.reverse();
                 int len = 4 - hex4.length();
@@ -1115,7 +1115,7 @@
     /**
      * Returns native handle for the top Windows node for this node.
      */
-    private int rootNativeHandle() {
+    private long rootNativeHandle() {
         return (isUserNode()
                 ? USER_ROOT_NATIVE_HANDLE
                 : SYSTEM_ROOT_NATIVE_HANDLE);
--- a/src/java.prefs/windows/native/libprefs/WindowsPreferences.c	Thu Mar 08 11:21:57 2018 +0900
+++ b/src/java.prefs/windows/native/libprefs/WindowsPreferences.c	Thu Mar 08 08:17:26 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,222 +37,222 @@
  */
 DEF_STATIC_JNI_OnLoad
 
-    JNIEXPORT jintArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegOpenKey
-               (JNIEnv* env, jclass this_class, jint hKey, jbyteArray lpSubKey, jint securityMask) {
-        HKEY handle;
-        char* str;
-        int tmp[2];
-        int errorCode=-1;
-        jintArray result;
-        str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
-        CHECK_NULL_RETURN(str, NULL);
-        errorCode =  RegOpenKeyEx((HKEY)hKey, str, 0, securityMask, &handle);
-        (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0);
-        tmp[0]= (int) handle;
-        tmp[1]= errorCode;
-        result = (*env)->NewIntArray(env,2);
-        if (result != NULL) {
-            (*env)->SetIntArrayRegion(env, result, 0, 2, tmp);
-        }
-        return result;
+JNIEXPORT jlongArray JNICALL
+Java_java_util_prefs_WindowsPreferences_WindowsRegOpenKey(JNIEnv* env,
+    jclass this_class, jlong hKey, jbyteArray lpSubKey, jint securityMask) {
+    char* str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
+    CHECK_NULL_RETURN(str, NULL);
+
+    HKEY handle;
+    int errorCode = RegOpenKeyEx((HKEY) hKey, str, 0, securityMask, &handle);
+    (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0);
+
+    jlong tmp[2];
+    tmp[0] = (jlong) handle;
+    tmp[1] = errorCode;
+    jlongArray result = (*env)->NewLongArray(env, 2);
+    if (result != NULL) {
+        (*env)->SetLongArrayRegion(env, result, 0, 2, tmp);
+    }
+    return result;
+}
+
+JNIEXPORT jint JNICALL
+Java_java_util_prefs_WindowsPreferences_WindowsRegCloseKey(JNIEnv* env,
+    jclass this_class, jlong hKey) {
+    return (jint) RegCloseKey((HKEY) hKey);
+};
+
+JNIEXPORT jlongArray JNICALL
+Java_java_util_prefs_WindowsPreferences_WindowsRegCreateKeyEx(JNIEnv* env,
+    jclass this_class, jlong hKey, jbyteArray lpSubKey) {
+    char* str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
+    CHECK_NULL_RETURN(str, NULL);
+
+    HKEY handle;
+    DWORD lpdwDisposition;
+    int errorCode = RegCreateKeyEx((HKEY) hKey, str, 0, NULL,
+        REG_OPTION_NON_VOLATILE, KEY_READ,
+        NULL, &handle, &lpdwDisposition);
+    (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0);
+
+    jlong tmp[3];
+    tmp[0] = (jlong) handle;
+    tmp[1] = errorCode;
+    tmp[2] = lpdwDisposition;
+    jlongArray result = (*env)->NewLongArray(env, 3);
+    if (result != NULL) {
+        (*env)->SetLongArrayRegion(env, result, 0, 3, tmp);
+    }
+    return result;
+}
+
+JNIEXPORT jint JNICALL
+Java_java_util_prefs_WindowsPreferences_WindowsRegDeleteKey(JNIEnv* env,
+    jclass this_class, jlong hKey, jbyteArray lpSubKey) {
+    char* str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
+    CHECK_NULL_RETURN(str, -1);
+
+    int result = RegDeleteKey((HKEY) hKey, str);
+    (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0);
+    return result;
+
+};
+
+JNIEXPORT jint JNICALL
+Java_java_util_prefs_WindowsPreferences_WindowsRegFlushKey(JNIEnv* env,
+    jclass this_class, jlong hKey) {
+    return RegFlushKey((HKEY) hKey);
+}
+
+JNIEXPORT jbyteArray JNICALL
+Java_java_util_prefs_WindowsPreferences_WindowsRegQueryValueEx(JNIEnv* env,
+    jclass this_class, jlong hKey, jbyteArray valueName) {
+    char* valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
+    CHECK_NULL_RETURN(valueNameStr, NULL);
+
+    DWORD valueType;
+    DWORD valueSize;
+    if (RegQueryValueEx((HKEY) hKey, valueNameStr, NULL, &valueType, NULL,
+        &valueSize) != ERROR_SUCCESS) {
+        (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
+        return NULL;
     }
 
-    JNIEXPORT jint JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegCloseKey
-               (JNIEnv* env, jclass this_class, jint hKey) {
-        return (jint) RegCloseKey((HKEY) hKey);
-    };
-
-    JNIEXPORT jintArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegCreateKeyEx
-               (JNIEnv* env, jclass this_class, jint hKey, jbyteArray lpSubKey) {
-        HKEY handle;
-        char* str;
-        int tmp[3];
-        DWORD lpdwDisposition;
-        int errorCode;
-        jintArray result = NULL;
-        str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
-        CHECK_NULL_RETURN(str, NULL);
-        errorCode =  RegCreateKeyEx((HKEY)hKey, str, 0, NULL,
-                      REG_OPTION_NON_VOLATILE, KEY_READ,
-                      NULL, &handle, &lpdwDisposition);
-        (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0);
-        tmp[0]= (int) handle;
-        tmp[1]= errorCode;
-        tmp[2]= lpdwDisposition;
-        result = (*env)->NewIntArray(env,3);
-        if (result != NULL) {
-            (*env)->SetIntArrayRegion(env, result, 0, 3, tmp);
-        }
-        return result;
-    }
-
-    JNIEXPORT jint JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegDeleteKey
-              (JNIEnv* env, jclass this_class, jint hKey, jbyteArray lpSubKey) {
-        char* str;
-        int result;
-        str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
-        CHECK_NULL_RETURN(str, -1);
-        result = RegDeleteKey((HKEY)hKey, str);
-        (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0);
-        return  result;
-
-    };
-
-    JNIEXPORT jint JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegFlushKey
-        (JNIEnv* env, jclass this_class, jint hKey) {
-        return RegFlushKey ((HKEY)hKey);
-        }
-
-    JNIEXPORT jbyteArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegQueryValueEx
-         (JNIEnv* env, jclass this_class, jint hKey, jbyteArray valueName) {
-        char* valueNameStr;
-        char* buffer;
-        jbyteArray result;
-        DWORD valueType;
-        DWORD valueSize;
-        valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
-        CHECK_NULL_RETURN(valueNameStr, NULL);
-        if (RegQueryValueEx((HKEY)hKey, valueNameStr, NULL, &valueType, NULL,
-                                                 &valueSize) != ERROR_SUCCESS) {
-        (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
-        return NULL;
-        }
-
-        buffer = (char*)malloc(valueSize);
-        if (buffer != NULL) {
-            if (RegQueryValueEx((HKEY)hKey, valueNameStr, NULL, &valueType, buffer,
-                &valueSize) != ERROR_SUCCESS) {
-                free(buffer);
-                (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
-                return NULL;
-            }
-        } else {
-            JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+    char* buffer = (char*) malloc(valueSize);
+    if (buffer != NULL) {
+        if (RegQueryValueEx((HKEY) hKey, valueNameStr, NULL, &valueType, buffer,
+            &valueSize) != ERROR_SUCCESS) {
+            free(buffer);
             (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
             return NULL;
         }
-
-        if (valueType == REG_SZ) {
-            result = (*env)->NewByteArray(env, valueSize);
-            if (result != NULL) {
-                (*env)->SetByteArrayRegion(env, result, 0, valueSize, buffer);
-            }
-        } else {
-            result = NULL;
-        }
-        free(buffer);
+    } else {
+        JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
         (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
-        return result;
-    }
-
-
-
-
-    JNIEXPORT jint JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegSetValueEx
-    (JNIEnv* env, jclass this_class, jint hKey, jbyteArray valueName, jbyteArray data) {
-        char* valueNameStr;
-        char* dataStr;
-        int size = -1;
-        int nameSize = -1;
-        int error_code = -1;
-        if ((valueName == NULL)||(data == NULL)) {return -1;}
-        size = (*env)->GetArrayLength(env, data);
-        dataStr = (*env)->GetByteArrayElements(env, data, NULL);
-        CHECK_NULL_RETURN(dataStr, -1);
-        valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
-        if (valueNameStr != NULL) {
-            error_code = RegSetValueEx((HKEY)hKey, valueNameStr, 0,
-                                                        REG_SZ, dataStr, size);
-            (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
-        }
-        (*env)->ReleaseByteArrayElements(env, data, dataStr, 0);
-        return error_code;
+        return NULL;
     }
 
-     JNIEXPORT jint JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegDeleteValue
-            (JNIEnv* env, jclass this_class, jint hKey, jbyteArray valueName) {
-        char* valueNameStr;
-        int error_code = -1;
-        if (valueName == NULL) {return -1;}
-        valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
-        CHECK_NULL_RETURN(valueNameStr, -1);
-        error_code = RegDeleteValue((HKEY)hKey, valueNameStr);
+    jbyteArray result;
+    if (valueType == REG_SZ) {
+        result = (*env)->NewByteArray(env, valueSize);
+        if (result != NULL) {
+            (*env)->SetByteArrayRegion(env, result, 0, valueSize, buffer);
+        }
+    } else {
+        result = NULL;
+    }
+    free(buffer);
+    (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
+    return result;
+}
+
+JNIEXPORT jint JNICALL
+Java_java_util_prefs_WindowsPreferences_WindowsRegSetValueEx(JNIEnv* env,
+    jclass this_class, jlong hKey, jbyteArray valueName, jbyteArray data) {
+    if ((valueName == NULL) || (data == NULL)) {
+        return -1;
+    }
+    int size = (*env)->GetArrayLength(env, data);
+    char* dataStr = (*env)->GetByteArrayElements(env, data, NULL);
+    CHECK_NULL_RETURN(dataStr, -1);
+
+    char* valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
+    int error_code = -1;
+    if (valueNameStr != NULL) {
+        error_code = RegSetValueEx((HKEY) hKey, valueNameStr, 0,
+            REG_SZ, dataStr, size);
         (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
-        return error_code;
-     }
+    }
+    (*env)->ReleaseByteArrayElements(env, data, dataStr, 0);
+    return error_code;
+}
+
+JNIEXPORT jint JNICALL
+Java_java_util_prefs_WindowsPreferences_WindowsRegDeleteValue(JNIEnv* env,
+    jclass this_class, jlong hKey, jbyteArray valueName) {
+    if (valueName == NULL) {
+        return -1;
+    }
+    char* valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
+    CHECK_NULL_RETURN(valueNameStr, -1);
 
-    JNIEXPORT jintArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegQueryInfoKey
-                                  (JNIEnv* env, jclass this_class, jint hKey) {
-        jintArray result = NULL;
-        int tmp[5];
-        int valuesNumber = -1;
-        int maxValueNameLength = -1;
-        int maxSubKeyLength = -1;
-        int subKeysNumber = -1;
-        int errorCode = -1;
-        errorCode = RegQueryInfoKey((HKEY)hKey, NULL, NULL, NULL,
-                 &subKeysNumber, &maxSubKeyLength, NULL,
-                 &valuesNumber, &maxValueNameLength,
-                 NULL, NULL, NULL);
-        tmp[0]= subKeysNumber;
-        tmp[1]= (int)errorCode;
-        tmp[2]= valuesNumber;
-        tmp[3]= maxSubKeyLength;
-        tmp[4]= maxValueNameLength;
-        result = (*env)->NewIntArray(env,5);
-        if (result != NULL) {
-            (*env)->SetIntArrayRegion(env, result, 0, 5, tmp);
-        }
-        return result;
+    int error_code = RegDeleteValue((HKEY) hKey, valueNameStr);
+    (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
+    return error_code;
+}
+
+JNIEXPORT jlongArray JNICALL
+Java_java_util_prefs_WindowsPreferences_WindowsRegQueryInfoKey(JNIEnv* env,
+    jclass this_class, jlong hKey) {
+    int subKeysNumber;
+    int maxSubKeyLength;
+    int valuesNumber;
+    int maxValueNameLength;
+    int errorCode = RegQueryInfoKey((HKEY) hKey, NULL, NULL, NULL,
+        &subKeysNumber, &maxSubKeyLength, NULL,
+        &valuesNumber, &maxValueNameLength,
+        NULL, NULL, NULL);
+
+    jlong tmp[5];
+    tmp[0] = subKeysNumber;
+    tmp[1] = errorCode;
+    tmp[2] = valuesNumber;
+    tmp[3] = maxSubKeyLength;
+    tmp[4] = maxValueNameLength;
+    jintArray result = (*env)->NewLongArray(env, 5);
+    if (result != NULL) {
+        (*env)->SetLongArrayRegion(env, result, 0, 5, tmp);
+    }
+    return result;
+}
+
+JNIEXPORT jbyteArray JNICALL
+Java_java_util_prefs_WindowsPreferences_WindowsRegEnumKeyEx(JNIEnv* env,
+    jclass this_class, jlong hKey, jint subKeyIndex, jint maxKeyLength) {
+    int size = maxKeyLength;
+    char* buffer = (char*) malloc(maxKeyLength);
+    if (buffer == NULL) {
+        JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+        return NULL;
+    }
+    if (RegEnumKeyEx((HKEY) hKey, subKeyIndex, buffer, &size, NULL, NULL,
+        NULL, NULL) != ERROR_SUCCESS) {
+        free(buffer);
+        return NULL;
     }
 
-     JNIEXPORT jbyteArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegEnumKeyEx
-     (JNIEnv* env, jclass this_class, jint hKey , jint subKeyIndex, jint maxKeyLength) {
-        int size = maxKeyLength;
-        jbyteArray result;
-        char* buffer = NULL;
-        buffer = (char*)malloc(maxKeyLength);
-        if (buffer == NULL) {
-            JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
-            return NULL;
-        }
-        if (RegEnumKeyEx((HKEY) hKey, subKeyIndex, buffer, &size, NULL, NULL,
-                                                 NULL, NULL) != ERROR_SUCCESS){
+    jbyteArray result = (*env)->NewByteArray(env, size + 1);
+    if (result != NULL) {
+        (*env)->SetByteArrayRegion(env, result, 0, size + 1, buffer);
+    }
+    free(buffer);
+    return result;
+}
+
+JNIEXPORT jbyteArray JNICALL
+Java_java_util_prefs_WindowsPreferences_WindowsRegEnumValue(JNIEnv* env,
+    jclass this_class, jlong hKey, jint valueIndex, jint maxValueNameLength) {
+    int size = maxValueNameLength;
+    char* buffer = (char*) malloc(maxValueNameLength);
+    if (buffer == NULL) {
+        JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+        return NULL;
+    }
+
+    int error_code = RegEnumValue((HKEY) hKey, valueIndex, buffer,
+        &size, NULL, NULL, NULL, NULL);
+    if (error_code != ERROR_SUCCESS) {
         free(buffer);
         return NULL;
-        }
-        result = (*env)->NewByteArray(env, size + 1);
-        if (result != NULL) {
-            (*env)->SetByteArrayRegion(env, result, 0, size + 1, buffer);
-        }
-        free(buffer);
-        return result;
-     }
-
-     JNIEXPORT jbyteArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegEnumValue
-          (JNIEnv* env, jclass this_class, jint hKey , jint valueIndex, jint maxValueNameLength){
-          int size = maxValueNameLength;
-          jbyteArray result;
-          char* buffer = NULL;
-          int error_code;
-          buffer = (char*)malloc(maxValueNameLength);
-          if (buffer == NULL) {
-              JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
-              return NULL;
-          }
-          error_code = RegEnumValue((HKEY) hKey, valueIndex, buffer,
-                                             &size, NULL, NULL, NULL, NULL);
-          if (error_code!= ERROR_SUCCESS){
-            free(buffer);
-            return NULL;
-          }
-          result = (*env)->NewByteArray(env, size + 1);
-          if (result != NULL) {
-              (*env)->SetByteArrayRegion(env, result, 0, size + 1, buffer);
-          }
-          free(buffer);
-          return result;
-     }
+    }
+    jbyteArray result = (*env)->NewByteArray(env, size + 1);
+    if (result != NULL) {
+        (*env)->SetByteArrayRegion(env, result, 0, size + 1, buffer);
+    }
+    free(buffer);
+    return result;
+}
 
 
 #ifdef __cplusplus