Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-866

Arrays.binarySearch should always return -1on empty array

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • None
    • Classlib
    • None
    • Windows XP
    • Novice

    Description

      Harmony: classlib + VM revision 421248

      If we try to find a non-comparable item in an empty array, RI returns -1 while Harmony throws ClassCastException.

      Code to reproduce:

      import java.util.*;

      public class Test {
      public static void main (String[] args) {
      System.err.println(Arrays.binarySearch(new Object[] {}, new Object()) == -1 ? "PASSED" : "FAILED");
      }
      }
      -------

      Please see the patch with unit test for this case and fix for classlib code attached

      Attachments

        1. patch.txt
          1 kB
          Anton Luht
        2. Harmony-866.diff
          2 kB
          spark shen

        Activity

          People

            paulex Paulex Yang
            aluht Anton Luht
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: