The Java VM write the follow debug output to System.error.
19.02.2009 08:51:11 java.util.prefs.WindowsPreferences openKey
WARNUNG: Could not open windows registry node Software\JavaSoft\Prefs\com\inet\report\config\cc at root 0x80000002. Windows RegOpenKey(...) returned error code 5.
This occur if we access to a not writable part of the preferences.
Because the method throw a SecurityException which we catch there is no need
to write debug output to the console.
This is a regression. It occur in Java 1.6.0_11 and 1.6.0_12 but not in 1.6.0_02.
��The stacktrace of the correct SecurityException is:
java.lang.SecurityException: Could not open windows registry node Software\JavaSoft\Prefs\com\inet\report\config\cc at root 0x80000002: Access denied
���������� at java.util.prefs.WindowsPreferences.openKey(WindowsPreferences.java:496)
���������� at java.util.prefs.WindowsPreferences.openKey(WindowsPreferences.java:463)
���������� at java.util.prefs.WindowsPreferences.openKey(WindowsPreferences.java:449)
���������� at java.util.prefs.WindowsPreferences.putSpi(WindowsPreferences.java:595)
���������� at java.util.prefs.AbstractPreferences.put(AbstractPreferences.java:234)
���������� at com.inet.lib.util.PreferencesUtils.isWriteable(PreferencesUtils.java:133)
���������� at com.inet.lib.util.PreferencesUtils.isSystemWriteable(PreferencesUtils.java:40)
The OS is Windows Vista with enabled UAC. ��That the system preferences are not writeable.
Code snippet attached:
public static void main(String[] args) {
isWriteable("/com/inet/report/config/cc ", true ));
}
private static boolean isWriteable( String path, boolean isSystem ) {
Preferences prefs = null;
try {
if( isSystem ) {
prefs = systemRoot();
} else {
prefs = userRoot();
}
boolean deleteAfterwards = false;
if (!prefs.nodeExists( path )) {
deleteAfterwards = true;
}
prefs = prefs.node( path );
prefs.put( "dummy", "nothing" );
prefs.flush();
prefs.sync();
if (deleteAfterwards) {
prefs.removeNode();
prefs.flush();
} else {
prefs.remove( "dummy" );
prefs.flush();
prefs.sync();
}
} catch( BackingStoreException e ) {
return false;
} catch( SecurityException ex ) {
return false;
}
return true;
}