Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7039586

test/java/util/Collections/Rotate.java failing with hs21-b09

XMLWordPrintable

    • b09
    • b11
    • generic
    • generic
    • Verified

        The jdk regression test java/util/Collections/Rotate.java has started failing in jdk7-b139 (hs21-b09). jdk7-b138 (hs21-b08) is okay. The failure can also be reproduced by copying hs21-b09 server/libjvm.so into a b138 image. Duplicates on serveral platforms, including linux-i586 and solaris-sparc. Doesn't duplicate with client VM.

        The test is in the jdk repository but duplicated here as it is short and standalone.


        import java.util.*;

        public class Rotate {
            // Should have lots of distinct factors and be > ROTATE_THRESHOLD
            static final int SIZE = 120;

            static Random rnd = new Random();

            public static void main(String[] args) throws Exception {
                List a[] = {new ArrayList(), new LinkedList(), new Vector()};

                for (int i=0; i<a.length; i++) {
                    List lst = a[i];
                    for (int j=0; j<SIZE; j++)
                        lst.add(new Integer(j));
                    int totalDist = 0;

                    for (int j=0; j<10000; j++) {
                        int dist = rnd.nextInt(200) - 100;
                        Collections.rotate(lst, dist);

                        // Check that things are as they should be
                        totalDist = (totalDist + dist) % SIZE;
                        if (totalDist < 0)
                            totalDist += SIZE;
                        int index =0;
                        for (int k=totalDist; k<SIZE; k++, index++)
                            if (((Integer)lst.get(k)).intValue() != index)
                                throw new Exception("j: "+j+", lst["+k+"]="+lst.get(k)+
                                                    ", should be "+index);
                        for (int k=0; k<totalDist; k++, index++)
                            if (((Integer)lst.get(k)).intValue() != index)
                                throw new Exception("j: "+j+", lst["+k+"]="+lst.get(k)+
                                                    ", should be "+index);
                    }
                }
            }
        }

              kvn Vladimir Kozlov
              alanb Alan Bateman
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: