-
Bug
-
Resolution: Incomplete
-
P4
-
None
-
8u121
-
x86_64
-
windows_10
FULL PRODUCT VERSION :
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 10.0.14393]
A DESCRIPTION OF THE PROBLEM :
When using Preferences API to store preferences for all users.
Preferences prefs = Preferences.systemRoot().node("com/example/application");
Calling prefs.put(...) puts the value somewhere in HKEY_LOCAL_MACHINE. But when calling prefs.get(..) it is searching for the value somewhere in HKEY_USERS.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
allUsersPreferences.put(preferencesKey, "value"); should put the value under HKEY_USERS/S-1-5-21-2949271145-287329799-4077743999-1001/SOFTWARE/JavaSoft/Prefs/com/example/application
ACTUAL -
allUsersPreferences.put(preferencesKey, "value"); is putting the value under HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Prefs/com/example/application
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Feb 13, 2017 11:17:50 AM java.util.prefs.WindowsPreferences <init>
WARNING: Could not create windows registry node Software\JavaSoft\Prefs\com at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
Feb 13, 2017 11:17:50 AM java.util.prefs.WindowsPreferences WindowsRegOpenKey1
WARNING: Trying to recreate Windows registry node Software\JavaSoft\Prefs\com at root 0x80000002.
Feb 13, 2017 11:17:50 AM java.util.prefs.WindowsPreferences openKey
WARNING: Could not open windows registry node Software\JavaSoft\Prefs\com at root 0x80000002. Windows RegOpenKey(...) returned error code 2.
Feb 13, 2017 11:17:50 AM java.util.prefs.WindowsPreferences WindowsRegOpenKey1
WARNING: Trying to recreate Windows registry node Software\JavaSoft\Prefs\com\example at root 0x80000002.
Feb 13, 2017 11:17:50 AM java.util.prefs.WindowsPreferences openKey
WARNING: Could not open windows registry node Software\JavaSoft\Prefs\com\example at root 0x80000002. Windows RegOpenKey(...) returned error code 2.
Feb 13, 2017 11:17:50 AM java.util.prefs.WindowsPreferences WindowsRegOpenKey1
WARNING: Trying to recreate Windows registry node Software\JavaSoft\Prefs\com\example\application at root 0x80000002.
Feb 13, 2017 11:17:50 AM java.util.prefs.WindowsPreferences openKey
WARNING: Could not open windows registry node Software\JavaSoft\Prefs\com\example\application at root 0x80000002. Windows RegOpenKey(...) returned error code 2.
Feb 13, 2017 11:17:50 AM java.util.prefs.WindowsPreferences WindowsRegOpenKey1
WARNING: Trying to recreate Windows registry node Software\JavaSoft\Prefs\com\example\application at root 0x80000002.
Feb 13, 2017 11:17:50 AM java.util.prefs.WindowsPreferences openKey
WARNING: Could not open windows registry node Software\JavaSoft\Prefs\com\example\application at root 0x80000002. Windows RegOpenKey(...) returned error code 2.
notFound
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.prefs.Preferences;
public class PreferencesBugTest {
public static void main(String[] args) {
Preferences allUsersPreferences = Preferences.systemRoot().node("com/example/application");
String preferencesKey = "key";
//This is put under HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Prefs/com/example/application
allUsersPreferences.put(preferencesKey, "value");
//This get method is looking under HKEY_USERS/S-1-5-21-2949271145-287329799-4077743999-1001/SOFTWARE/JavaSoft/Prefs/com/example/application so it prints "notFound"
System.out.println(allUsersPreferences.get(preferencesKey, "notFound"));
}
}
---------- END SOURCE ----------
SUPPORT :
YES
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 10.0.14393]
A DESCRIPTION OF THE PROBLEM :
When using Preferences API to store preferences for all users.
Preferences prefs = Preferences.systemRoot().node("com/example/application");
Calling prefs.put(...) puts the value somewhere in HKEY_LOCAL_MACHINE. But when calling prefs.get(..) it is searching for the value somewhere in HKEY_USERS.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
allUsersPreferences.put(preferencesKey, "value"); should put the value under HKEY_USERS/S-1-5-21-2949271145-287329799-4077743999-1001/SOFTWARE/JavaSoft/Prefs/com/example/application
ACTUAL -
allUsersPreferences.put(preferencesKey, "value"); is putting the value under HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Prefs/com/example/application
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Feb 13, 2017 11:17:50 AM java.util.prefs.WindowsPreferences <init>
WARNING: Could not create windows registry node Software\JavaSoft\Prefs\com at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
Feb 13, 2017 11:17:50 AM java.util.prefs.WindowsPreferences WindowsRegOpenKey1
WARNING: Trying to recreate Windows registry node Software\JavaSoft\Prefs\com at root 0x80000002.
Feb 13, 2017 11:17:50 AM java.util.prefs.WindowsPreferences openKey
WARNING: Could not open windows registry node Software\JavaSoft\Prefs\com at root 0x80000002. Windows RegOpenKey(...) returned error code 2.
Feb 13, 2017 11:17:50 AM java.util.prefs.WindowsPreferences WindowsRegOpenKey1
WARNING: Trying to recreate Windows registry node Software\JavaSoft\Prefs\com\example at root 0x80000002.
Feb 13, 2017 11:17:50 AM java.util.prefs.WindowsPreferences openKey
WARNING: Could not open windows registry node Software\JavaSoft\Prefs\com\example at root 0x80000002. Windows RegOpenKey(...) returned error code 2.
Feb 13, 2017 11:17:50 AM java.util.prefs.WindowsPreferences WindowsRegOpenKey1
WARNING: Trying to recreate Windows registry node Software\JavaSoft\Prefs\com\example\application at root 0x80000002.
Feb 13, 2017 11:17:50 AM java.util.prefs.WindowsPreferences openKey
WARNING: Could not open windows registry node Software\JavaSoft\Prefs\com\example\application at root 0x80000002. Windows RegOpenKey(...) returned error code 2.
Feb 13, 2017 11:17:50 AM java.util.prefs.WindowsPreferences WindowsRegOpenKey1
WARNING: Trying to recreate Windows registry node Software\JavaSoft\Prefs\com\example\application at root 0x80000002.
Feb 13, 2017 11:17:50 AM java.util.prefs.WindowsPreferences openKey
WARNING: Could not open windows registry node Software\JavaSoft\Prefs\com\example\application at root 0x80000002. Windows RegOpenKey(...) returned error code 2.
notFound
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.prefs.Preferences;
public class PreferencesBugTest {
public static void main(String[] args) {
Preferences allUsersPreferences = Preferences.systemRoot().node("com/example/application");
String preferencesKey = "key";
//This is put under HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Prefs/com/example/application
allUsersPreferences.put(preferencesKey, "value");
//This get method is looking under HKEY_USERS/S-1-5-21-2949271145-287329799-4077743999-1001/SOFTWARE/JavaSoft/Prefs/com/example/application so it prints "notFound"
System.out.println(allUsersPreferences.get(preferencesKey, "notFound"));
}
}
---------- END SOURCE ----------
SUPPORT :
YES