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

Expand use of representation equivalence terminology

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 26
    • core-libs

      JDK-8294539 introduced the term "representation equivalence" (among other terms) to describe one equivalence relation used by compare floating-point numbers. Besides in the equals and compareTo methods of Float and Double, the semantics of representation equivalence are appear in the discussion of the equivalence of records:

      From java.lang.Record::equals:

      Implementation Requirements:
          The implicitly provided implementation returns true if and only if the argument is an instance of the same record class as this record, and each component of this record is equal to the corresponding component of the argument; otherwise, false is returned. Equality of a component c is determined as follows:

             * If the component is of a reference type, the component is considered equal if and only if Objects.equals(this.c, r.c) would return true.
             * If the component is of a primitive type, using the corresponding primitive wrapper class PW (the corresponding wrapper class for int is java.lang.Integer, and so on), the component is considered equal if and only if PW.compare(this.c, r.c) would return 0.

          Apart from the semantics described above, the precise algorithm used in the implicitly provided implementation is unspecified and is subject to change. The implementation may or may not use calls to the particular methods listed, and may or may not perform comparisons in the order of component declaration.

      The documentation in these locations would be improved if "representation equivalence" was explicitly mentioned as a concept in addition to whatever coding idioms implementation representation equivalence were referred to.

            darcy Joe Darcy
            darcy Joe Darcy
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: