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

Arrays.binarySearch should always return -1on empty array

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Classlib
    • Labels:
      None
    • Environment:
      Windows XP
    • Estimated Complexity:
      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. Harmony-866.diff
          2 kB
          spark shen
        2. patch.txt
          1 kB
          Anton Luht

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: