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

java.lang.invoke.ObjectMethods.makeEquals() reverses the order of comparison

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      Lets have a record "Data(Long primaryKey, Details details)" and two instances of it, "a" and "b".

      The expected behaviour when calling "a.equals(b)" would be that the for records automatically generated code would test "a.primaryKey.equals(b.primaryKey)" at first.
      But actually "a.details.equals(b.details)" is tested at first.

      The cause is in ObjectMethods.makeEquals(). It should iterate in reverse order over the passed list of method handles.

      Semantically, it is not necessarily a bug, but developers usually are placing the most distinct properties before other, more expensive objects to compare.
      This can have extreme impact on application performance.
      It not seems logical to place the most distinct properties at the end of a record.


            liach Chen Liang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: