Harmony
  1. Harmony
  2. HARMONY-866

Arrays.binarySearch should always return -1on empty array

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor 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

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

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        66d 12h 21m 1 Paulex Yang 18/Sep/06 07:35
        Resolved Resolved Closed Closed
        4d 38m 1 Paulex Yang 22/Sep/06 08:13
        Paulex Yang made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Hide
        Paulex Yang added a comment -

        Verified by Anton and Spark.

        Show
        Paulex Yang added a comment - Verified by Anton and Spark.
        Hide
        Anton Luht added a comment -

        verified on build:
        svn = r447316, (Sep 18 2006), Windows/ia32/msvc 1310, debug build

        Show
        Anton Luht added a comment - verified on build: svn = r447316, (Sep 18 2006), Windows/ia32/msvc 1310, debug build
        Paulex Yang made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Hide
        Paulex Yang added a comment -

        Spark, patch applied at revision r447282, thanks a lot for this enhancement.

        Anton, please verify that the problem is fully fixed as you expected.

        Show
        Paulex Yang added a comment - Spark, patch applied at revision r447282, thanks a lot for this enhancement. Anton, please verify that the problem is fully fixed as you expected.
        Paulex Yang made changes -
        Assignee Paulex Yang [ paulex ]
        Hide
        Anton Luht added a comment -

        I've applied this patch successfully to r443308 - it solved the problem.

        Show
        Anton Luht added a comment - I've applied this patch successfully to r443308 - it solved the problem.
        spark shen made changes -
        Attachment Harmony-866.diff [ 12340807 ]
        Hide
        spark shen added a comment -

        This is the new patch. Would you please have a try?

        Best regards

        Show
        spark shen added a comment - This is the new patch. Would you please have a try? Best regards
        Nathan Beyer made changes -
        Component/s Non-bug differences from RI [ 12310780 ]
        Component/s Classlib [ 12310560 ]
        Hide
        spark shen added a comment -

        I suggest to change the component attribute to classlib, since RI's behavior makes sense here.
        Refer to thread '[OLD JIRA]Deal with 780 866 1367 according to discussion'

        Show
        spark shen added a comment - I suggest to change the component attribute to classlib, since RI's behavior makes sense here. Refer to thread ' [OLD JIRA] Deal with 780 866 1367 according to discussion'
        Anton Luht made changes -
        Field Original Value New Value
        Attachment patch.txt [ 12336803 ]
        Hide
        Anton Luht added a comment -

        patch

        Show
        Anton Luht added a comment - patch
        Anton Luht created issue -

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development