JDK-6809488 : REGRESSION:SecurityException throws when JVM try to write debug putput to the console
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 6u12
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2009-02-24
  • Updated: 2010-08-16
  • Resolved: 2010-08-16
Related Reports
Duplicate :  
Description
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;

 }

Comments
EVALUATION There is a change in behavior between 6u7 and 6u10. Releases prior to 6u10 didn't specify the requestedExecutionLevel in the manifest of "java.exe" and so Windows Vista treated it as a legacy application. Legacy applications have access to the registry virtualized. In particular, write access to the registry is redirected to a per-user location ( HKEY_CURRENT_USER\Software\Classes\VirtualStore\SOFTWARE\JavaSoft\Prefs instead of KHEY_LOCAL_MACHINE\Software\JavaSoft\Prefs). 6u10 has the manifest in java.exe and so correctly fails with 6u10 and newer updates. The bug description is confusing but I think the submitter is saying that he/she is seeing WARNING messages on the console where they weren't there before. These WARNING messages are coming from the logger used in the preference implementation. These messages can be suppressed by changing the logging level, eg: edit $JAVA_HOME/lib/logging.properties and add the line: java.util.prefs.level = SEVERE The logging level and messages have not changed for several releases. The reason they are visible now is because access to the registry is correctly failing (previously it was also failing but the access was silently redirected by Windows Vista to a per-user location).
02-03-2009

EVALUATION This bug report needs more information. Which edition of Windows is this? Is there a test case or any sample code that demonstrates the issue?
25-02-2009