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

Add java.util.Objects.newIdentity method

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P3 P3
    • None
    • None
    • core-libs
    • None

      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.)

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

              Created:
              Updated:
              Resolved: