[kaffe] LinkedList.subList severely broken

Daniel Bonniot Daniel.Bonniot@inria.fr
Wed May 21 02:42:01 2003


This is a multi-part message in MIME format.
--------------050401060105070801000904
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit


Hi,

I'm in the process of testing kaffe with a compiler I am writing. My 
hope is that 1.1 will be able to run it.
It used to work with CVS a few weeks ago, but there has been a 
regression. I have a precise testcase for LinkedList.subList. Has this 
been touched recently?

Is kaffe passing the testcases (mauve or others) for java.util 
collections? If yes, it seems that the tests are not thorough enough 
yet. This test should then be added to mauve. I am a bit reluctant to do 
it, though, since my one submission was hapilly and silently ignored. It 
seems there is little activity on mauve, which is a shame.
LinkedList seem to come from classpath. Maybe it is broken there too, 
then...

Please fix this bug before the release. It seems like a simple 
off-by-one error. (unfortunately I have no time to look at the moment). 
But it is very annoying, as this does not cause any kind of exception, 
but the semantics is wrong, so it's not so easy to spot.

Cheers,

Daniel


--------------050401060105070801000904
Content-Type: text/x-java;
 name="SubListTest.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="SubListTest.java"

import java.util.*;

public class SubListTest
{
  public static void main(String[] args)
  {
    testSubList(new LinkedList());
  }

  static void testSubList(List list)
  {
    list.clear();
    list.add("0");
    list.add("1");
    list.add("2");
    list.add("3");
    
    final int start = 1, end = 3;

    List sub = list.subList(start,end);
    System.out.println(sub);
    if (! (sub.get(0).equals(list.get(1))))
      throw new Error("Bug in get");

    Iterator it = sub.iterator();
    int i = 1;
    while (it.hasNext())
      {
        if (! (it.next().equals(list.get(i))))
          throw new Error("Bug in interator");
        i++;
      }

    if (i != end)
      throw new Error("Bug in interator");
  }
}

--------------050401060105070801000904--