(prefs) Bad example of userNodeForPackage and systemNodeForPackage in Preferences API

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 6
    • Affects Version/s: 1.4.0, 5.0
    • Component/s: core-libs
    • b95
    • x86
    • windows_2000

      Name: rmT116609 Date: 01/26/2003


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

      A DESCRIPTION OF THE PROBLEM :
      The examples of how to use preferences API in the
      http://java.sun.com/j2se/1.4/docs/guide/lang/preferences.html guide use:
         Preferences prefs = Preferences.userNodeForPackage(this);
      and
         Preferences prefs = Preferences.systemNodeForPackage(this);

      According the API's doc and the actual interface availible with the JDK, these methods expects an object of class "Class" and not "Object". Because of this, the examples fails to compile.

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package com.acme.widget;
      import java.util.prefs.*;

      public class Gadget {
          // Preference keys for this package
          private static final String NUM_ROWS = "num_rows";
          private static final String NUM_COLS = "num_cols";

          void foo() {
              Preferences prefs = Preferences.userNodeForPackage(this);

              int numRows = prefs.getInt(NUM_ROWS, 40);
              int numCols = prefs.getInt(NUM_COLS, 80);

              ...
          }
      }


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

            Assignee:
            Xueming Shen
            Reporter:
            Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: