Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4696941

underscore in package name corrupts Preferences node directory names

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 1.4.0
    • core-libs
    • x86
    • solaris_8



      Name: nt126004 Date: 06/04/2002


      FULL PRODUCT VERSION :
      java version "1.4.0-rc"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b89)
      Java HotSpot(TM) Client VM (build 1.4.0-rc-b89, mixed mode)


      FULL OPERATING SYSTEM VERSION :
      SunOS d007022.smo.av.com 5.8 Generic_108529-07 i86pc i386 i86pc


      A DESCRIPTION OF THE PROBLEM :
      Preferences.userNodeForPackage() and
      Preferences.systemNodeForPackage() produce corrupt (see
      example below) node names under the ".java" tree if
      an underscore is included in the package name.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1.try the Preferences example show on this page:

      http://www.onjava.com/pub/a/onjava/2002/03/06/topten.html

        It's sufficient to wrap it in a simple "psvm" main() (see source below).

        Give it the package statement:
        package under_score;


      2. compile and run it
      3. note the name created under ".../.java/.userPrefs/..."





      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Expected:
       .../.java/.userPrefs/under_score

      Actual:
       .../.java/.userPrefs/_!(`!bg"k!'`!cg"f!(:!}w"v!()!~@==

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      None.

      Note that although the Coding Conventions say use only lower-case letters
      package names with "_" are perfectly valid and produce correct output - except
      for this Preferences problem.

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package under_score;

      import java.util.prefs.*;

      public class X {


              public static void main(String[] args) {
      // Get Preferences objects for user and system preferences for the package
      // that contains the TextEditor class.
      Preferences userprefs = Preferences.userNodeForPackage(TextEditor.class);
      Preferences sysprefs = Preferences.systemNodeForPackage(TextEditor.class);

      // Look up a user preference value as an integer.
      // Note that we always pass a default value
      int width = userprefs.getInt("width", 80);
      // Look up a user preference using a system preference as the default
      String dictionary = userprefs.get("dictionary"
      sysprefs.get("dictionary",
      "default_dictionary"));
              }


      }

      ---------- END SOURCE ----------
      (Review ID: 148127)
      ======================================================================

            kkladkosunw Konstantin Kladko (Inactive)
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: