10
|
1 |
/*
|
|
2 |
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*/
|
|
23 |
|
|
24 |
/*
|
|
25 |
* @test
|
|
26 |
* @bug 6320536
|
|
27 |
* @summary com.sun.tools.javac.util.List.from(A[]) shouldn't be deprecated
|
|
28 |
* @author Peter von der Ah\u00e9
|
|
29 |
* @library ../..
|
|
30 |
* @compile ../../util/list/AbstractList.java
|
|
31 |
* @run main util.list.AbstractList
|
|
32 |
*/
|
|
33 |
|
|
34 |
package util.list;
|
|
35 |
|
|
36 |
import static com.sun.tools.javac.util.List.from;
|
|
37 |
import java.util.List;
|
|
38 |
|
|
39 |
public class AbstractList {
|
|
40 |
public static void test(String... args) {
|
|
41 |
List<String> ss = from(args);
|
|
42 |
if (args != null) {
|
|
43 |
int index = 0;
|
|
44 |
for (String s : args) {
|
|
45 |
if (s != ss.get(index))
|
|
46 |
throw new AssertionError("s != ss.get(" + index + ")");
|
|
47 |
index++;
|
|
48 |
}
|
|
49 |
boolean ok = false;
|
|
50 |
try {
|
|
51 |
ss.get(-1);
|
|
52 |
} catch(IndexOutOfBoundsException ex) {
|
|
53 |
ok = true;
|
|
54 |
}
|
|
55 |
if (!ok)
|
|
56 |
throw new AssertionError();
|
|
57 |
ok = false;
|
|
58 |
try {
|
|
59 |
ss.get(args.length);
|
|
60 |
} catch(IndexOutOfBoundsException ex) {
|
|
61 |
ok = true;
|
|
62 |
}
|
|
63 |
if (!ok)
|
|
64 |
throw new AssertionError();
|
|
65 |
}
|
|
66 |
}
|
|
67 |
public static void main(String... args) {
|
|
68 |
test();
|
|
69 |
test("foo");
|
|
70 |
test("foo", "bar");
|
|
71 |
test("foo", "bar", "bax", "qux", "hest", "fisk", "ko", "fugl");
|
|
72 |
System.out.println("List.get(int) test OK");
|
|
73 |
}
|
|
74 |
}
|