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

Add java.util.Objects.newIdentity method

    XMLWordPrintable

Details

    • Enhancement
    • Status: Resolved
    • P3
    • Resolution: Won't Fix
    • None
    • None
    • core-libs
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: