Provide a method caches the valueOf(String)

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Duplicate
    • Priority: P5
    • None
    • Affects Version/s: 6
    • Component/s: core-libs
    • x86
    • windows_xp

      A DESCRIPTION OF THE REQUEST :
      Currently these methods use a small cache
      Byte.valueOf(byte)
      Short.valueOf(short)
      Integer.valueOf(int)
      Long.valueOf(long)

      However these methods do not.
      Byte.valueOf(String)
      Short.valueOf(String)
      Integer.valueOf(String)
      Long.valueOf(String)

      Suggest having a method which takes a String and uses the same object pool as the valueOf(primative)

      JUSTIFICATION :
      It useful to pool objects converted from a String in the same way it is useful to wrap primative values.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      valueOf(String) should be pooled for the same values as valueOf(primative)
      ACTUAL -
      valueOf("0") returns a new object every time.

      CUSTOMER SUBMITTED WORKAROUND :
      use
      Long.valueOf(Long.parseLong(asStr));
      Integer.valueOf(Integer.parseInt(asStr));
      Short.valueOf(Short.parseShort(asStr));
      Byte.valueOf(Byte.parseByte(asStr));

            Assignee:
            Unassigned
            Reporter:
            Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: