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

(enum) Create an enum for standard System property keys.

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

      A DESCRIPTION OF THE REQUEST :
      Could get an enum for the standard System property keys?

      JUSTIFICATION :
      This would reduce programming errors.

      It is also quite cumbersome to write test cases that actually cover the possibility that the desired property name key has been misspelled in the code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      public final class System {

          public static String getProperty(final Property property) {
              return getProperty(property.getPropertyKey());
          }


          public enum Property {

              LINE_SEPARATOR() {
                  public String getPropertyKey() {
                      return "line.separator";
                  }
              };


              /** Returns the key's String value. */
              public abstract String getPropertyKey();

              /** Get the system property -- delegates to System.getProperty. */
              public String getPropertyValue() {
                  return getProperty(this);
              }

          }

      }

      ACTUAL -
      Problematic String literal property keys.

      ---------- BEGIN SOURCE ----------
      ...
      if (myVariable.equals(System.getProperty("1ine.separator")))
              ...
      else ...
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Define your own such enum.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                smarks Stuart Marks
                Reporter:
                jleesunw Jon Lee (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: