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

[classlib][luni] ArrayList may introduce data corruption.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 5.0M6
    • 5.0M6
    • Classlib
    • None
    • Patch Available

    Description

      Harmony's ArrayList may cause data corruption.
      The testcase is list as following:

      ArrayList list1 = new ArrayList();
      ArrayList list2 = new ArrayList();
      int location = 2;

      String[] strings =

      {"0","1","2","3","4","5","6"}

      ;
      int[] integers =

      {0,1,2,3,4,5,6,7,8,9}

      ;
      for (int i = 0; i < 7; i++)

      { list1.add(strings[i]); }

      for (int i = 0; i < 10; i++)

      { list2.add(integers[i]); }

      list1.remove(location);
      list1.addAll(location,list2);

      for(Object element: list1)

      { System.out.print(element+","); }

      RI will print
      "0", "1", 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "3", "4", "5", "6",
      While Harmony will print
      "0", "1", 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "1", "3", "4", "5",

      The "6" is missing and "1" is duplicated.

      Attachments

        1. Harmony-5799.diff
          3 kB
          Sean Qiu

        Activity

          People

            tellison Tim Ellison
            qiuxiaox Sean Qiu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: