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

Add java.util.Objects.newIdentity method

    XMLWordPrintable

    Details

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

      Description

      Introduce a method in the Objects utility class, something like:

      /**
       * Construct a new instance of an unspecified class. The object has
       * a unique identity—no other references to it exist. It can be
       * used for synchronization, or where a placeholder Object is
       * needed. Use this method to avoid relying on the Object constructor.
       */
      public static Object newIdentity() {
          return new Object() {};
      }

      (The method appears somewhat unmotivated for now, but with JEP 401, use of the Object constructor will be discouraged (with warnings) in Java source, and this method provides a migration path to something else.)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rriggs Roger Riggs
              Reporter:
              dlsmith Dan Smith
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: