harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Ellison (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (HARMONY-6141) [classlib][luni] java.util.ArrayList.addAll(int index, Collection<? extends E> c) fails to add itself
Date Wed, 06 May 2009 12:28:33 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-6141?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Tim Ellison resolved HARMONY-6141.
----------------------------------

       Resolution: Fixed
    Fix Version/s:     (was: 5.0M9)
                   5.0M10

I tried to rework it a few times, but got myself totally confused because some of the local
variables have already been modified before the collection is converted to an array, so the
instance is all messed up.

I think it would be simpler and just as efficient to clone the collection if it is being added
to itself.  What do you think?

Please take a look a the patch applied to the LUNI module at repo revision r772173.


> [classlib][luni] java.util.ArrayList.addAll(int index, Collection<? extends E>
c) fails to add itself
> -----------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-6141
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6141
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M8
>            Reporter: Kevin Zhou
>             Fix For: 5.0M10
>
>         Attachments: HARMONY-6141.diff
>
>
> Given a test case [1], both of these two scenarios are used to test java.util.ArrayList.addAll(int
index, Collection<? extends E> c) method.
> For scenario1, initialize two array list "arrayListA" and "arrayListB", add 1 to them
respectively; then invoke arrayListA.addAll(arrayListB); finally "arrayListA" should be like
[1, 1]
> For scenario2, initialize an array list "arrayList", add one element to it; then try
to add itself in the position of 1; finally "arrayList" should look like [1, 1] as well.
> Conduct this test scenarios on RI and HY, RI passes all while HY fails on the 2nd scenario.
> [1] Test Case:
> public void test_ArrayList_addAll_scenario1() {
>     ArrayList arrayListA = new ArrayList();
>     arrayListA.add(1);
>     ArrayList arrayListB = new ArrayList();
>     arrayListB.add(1);
>     arrayListA.addAll(1, arrayListB);
>     int size = arrayListA.size();
>     assertEquals(2, size);
>     for (int index = 0; index < size; index++) {
>         assertEquals(1, arrayListA.get(index));
>     }
> }
> public void test_ArrayList_addAll_scenario2() {
>     ArrayList arrayList = new ArrayList();
>     arrayList.add(1);
>     arrayList.addAll(1, arrayList);
>     int size = arrayList.size();
>     assertEquals(2, size);
>     for (int index = 0; index < size; index++) {
>         assertEquals(1, arrayList.get(index));
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message