< prev index next >

test/jdk/java/util/Collections/Swap.java

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.
--- 1,7 ---
  /*
!  * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

*** 24,12 ***
--- 24,14 ---
  /*
   * @test
   * @bug     4323074
   * @summary Basic test for newly public swap algorithm
   * @author  Josh Bloch
+  * @library /test/lib
   */
  
+ import jdk.test.lib.valueclass.VClass;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.List;
  
  public class Swap {

*** 43,7 ***
--- 45,13 ---
  
          List l2 = new ArrayList(Collections.nCopies(100, Boolean.FALSE));
          l2.set(SIZE-1, Boolean.TRUE);
          if (!l.equals(l2))
              throw new RuntimeException("Wrong result");
+ 
+         List<VClass> vl = new ArrayList<>(Collections.nCopies(SIZE, new VClass(0, new int[] { 0 })));
+         vl.set(0, new VClass(1, new int[] { 1 }));
+         for (int i = 0; i < SIZE - 1; i++) Collections.swap(vl, i, i + 1);
+         if (!vl.get(SIZE - 1).equals(new VClass(1, new int[] { 1 })))
+             throw new RuntimeException("value swap failed");
      }
  }
< prev index next >