Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8024970 André Bargull's list on Sep 17, 2013
  3. JDK-8026706

Inconsistent toString implementation in objects being sorted results in IllegalArgumentException

XMLWordPrintable

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



      jjs> function RandomObject() { this.toString = function() { return
      (Math.random() * 100).toString(); } }
      jjs> for (var j=0; j <100; ++j) {var arr = []; for (var i = 0; i < 64;
      ++i) arr[i] = new RandomObject; arr.sort();}

      Expected: no IllegalArgumentException is thrown
      Actual: java.lang.IllegalArgumentException: Comparison method violates
      its general contract!

            sundar Sundararajan Athijegannathan
            sundar Sundararajan Athijegannathan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: