JDK-8139507 : WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 8u60
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_7
  • CPU: x86
  • Submitted: 2015-10-09
  • Updated: 2019-03-19
  • Resolved: 2016-06-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u192Fixed 9 b123Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

A DESCRIPTION OF THE PROBLEM :
The warning:
  Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
is printed to stderr. This happens when accessing the userRoot.

This happens at least for jre installations of jre 1.7.0_21 and higher on a 'clean' Windows system. Installation of older jre versions create the key
  HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefs
Versions 1.7.21 and later and 1.8.0 and later do NOT.
Removing older version do not seem to remove the existing HKLM key. That is why this issue only occurs with installations on 'clean' Windows systems.
With an existing HKLM Prefs key, no warnings are generated.

******
This issue was reported earlier, see JDK-8038489. It was closed because it was said to be not reproducible.
It is however reproducible if HLKM\SOFTWARE\JavaSoft\Prefs is not present, like on clean Windows systems or if manually removed.

UAC is enabled, user which installs and runs is member of Administrators.

As I am not able to reopen it, I submit this as a new one with a little more detail on how to reproduce.

ADDITIONAL REGRESSION INFORMATION: 
Last worked in 1.7.0_13

JRE 1.8.0 installer does NOT create the HKLM Prefs key
JRE 1.7.0_21 (and higher) installer does NOT create the HKLM Prefs key
JRE 1.7.0_13 installer does create the HKLM Prefs key
_15 and _17 never tested. 

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Remove
  HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefs
from Windows registry. This 'Prefs' key is present if you ever had an older java version installed.

If you want you can install JRE/JDK 1.8.0_60, the Prefs key will not be created. Running the source code without the Prefs key in HKLM will report the warning.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No warning

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Oct 09, 2015 9:47:43 AM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package Bugs;

import java.util.prefs.Preferences;

public class PrefsWarning {

  void findPrefs() {
    Preferences prefs = Preferences.userRoot();
  }

  public static void main(String[] args) {
    PrefsWarning pw = new PrefsWarning();
    pw.findPrefs();
  }

}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Create HKLM Prefs key manually in Windows Registry
- or -
Install (very) old jre before installing a recent one.


Comments
Additional information is at https://bugs.openjdk.java.net/browse/JDK-8146335
30-12-2015

Following reasons given by user for treating this as bug , so re-opening for dev-team to evaluate: -------------------------------------------------------------------------------------------------- 1. This happens because the JRE installer no longer creates the HKLM Prefs entry. JRE version 1.7.0_13 and before created the entry (same rights, also UAC enabled), version 1.7.0_21 (and 1.8.0) stopped doing that. Did not test it on 1.7.0_15 and 1.7.0_17. 2. The warning makes no sense as the source code is NOT explicitly accessing the system root, only the user root. 3. I think it should be valid to run java with UAC enabled. 4. I found no way to prevent the warning from source code.
20-10-2015

Closing as not an issue, as per submitter's response.
13-10-2015

Could not reproduce with JDK 8u60 and 9EAb82, sending mail to submitter for additional inputs.
13-10-2015