JDK-7198073 : (prefs) user prefs not saved [macosx]
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86
  • Submitted: 2012-09-12
  • Updated: 2013-06-26
  • Resolved: 2012-10-16
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 7 JDK 8
7u40Fixed 8 b63Fixed
Description
FULL PRODUCT VERSION :
java version "1.7.0_10-ea"
Java(TM) SE Runtime Environment (build 1.7.0_10-ea-b06)
Java HotSpot(TM) 64-Bit Server VM (build 23.4-b01, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Mac OS X 10.7.4

A DESCRIPTION OF THE PROBLEM :
Java User Preferences no longer work with JDK 1.7.0_10-ea-b06 when run from the command line even though it works fine with the previous Oracle JDK 7 release (version 1.7.0_06) and Apple's JDK 1.6.0 releases. This problem only occurs when running java from the command line (e.g. in Terminal). If one runs the application by double clicking the jar file, preferences will load fine.

When using the latest JDK 7 release and running from the command line, the following preference is empty even though the corresponding preference file has an entry and it works with previous JDK releases:
        Preferences prefs = Preferences.userNodeForPackage( MyClass.class );



REGRESSION.  Last worked in version 7

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- Create a class and save preferences using:
        Preferences prefs = Preferences.userNodeForPackage( MyClass.class );
        prefs.put( "DEMO", "Success" );

- Dump preferences using:
        Preferences prefs = Preferences.userNodeForPackage( MyClass.class );
        String result = prefs.get( "DEMO", null );
        System.out.println( "Current Preference: " + result );

- Run the app using a previous version of the JDK to save the preferences and verify that the preferences are saved
- Run the app using JDK 1.7.0_10 from the command line: java -jar app.jar




EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When writing the preferences it should display "Current Preference: Success"
ACTUAL -
"Current Preference: "

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
Launch the jar by double clicking it in the Finder.

Comments
Changeset: 3a6b76a468bd Author: khazra Date: 2012-10-16 15:23 -0700 URL: http://hg.openjdk.java.net/jdk8/tl/jdk/rev/3a6b76a468bd 7198073: (prefs) user prefs not saved [macosx] Summary: Using class member field to get node instead of argument Reviewed-by: alanb ! src/macosx/classes/java/util/prefs/MacOSXPreferences.java + test/java/util/prefs/CheckUserPrefFirst.java + test/java/util/prefs/CheckUserPrefLater.java + test/java/util/prefs/CheckUserPrefsStorage.sh
16-10-2012