Thu, 15 Jul 2010 16:31:02 +0100
6967002: JDK7 b99 javac compilation error (java.lang.AssertionError)
Summary: bug in JavacParser related to parsing of type annotations in varargs position
Reviewed-by: jjg
Contributed-by: mahmood@notnoop.com
1 /*
2 * Copyright (c) 2002, 2004, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
24 /*
25 * @test
26 * @bug 4496290 4985072
27 * @summary A simple test to determine if -use works.
28 * @author jamieh
29 * @library ../lib/
30 * @build JavadocTester
31 * @build TestUseOption
32 * @run main TestUseOption
33 */
35 public class TestUseOption extends JavadocTester {
37 private static final String BUG_ID = "4496290-4985072";
39 //Input for string search tests.
40 private static final String[] TEST2 = {
41 "Field in C1.",
42 "Field in C2.",
43 "Field in C4.",
44 "Field in C5.",
45 "Field in C6.",
46 "Field in C7.",
47 "Field in C8.",
48 "Method in C1.",
49 "Method in C2.",
50 "Method in C4.",
51 "Method in C5.",
52 "Method in C6.",
53 "Method in C7.",
54 "Method in C8.",
55 };
57 private static final String[] ARGS = new String[] {
58 "-d", BUG_ID, "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2"
59 };
61 private static final String[] ARGS2 = new String[] {
62 "-d", BUG_ID+"-2", "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2"
63 };
65 /**
66 * The entry point of the test.
67 * @param args the array of command line arguments.
68 */
69 public static void main(String[] args) throws Exception {
70 String[][] tests = new String[11][2];
71 //Eight tests for class use.
72 for (int i = 0; i < 8; i++) {
73 tests[i][0] = BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html";
74 tests[i][1] = "Test " + (i + 1) + " passes";
75 }
76 //Three more tests for package use.
77 for (int i = 8, j = 1; i < tests.length; i++, j++) {
78 tests[i][0] = BUG_ID + FS + "pkg1" + FS + "package-use.html";
79 tests[i][1] = "Test " + j + " passes";
80 }
81 TestUseOption tester = new TestUseOption();
82 run(tester, ARGS, tests, NO_TEST);
83 tester.printSummary();
84 run(tester, ARGS2, NO_TEST, NO_TEST);
85 String usePageContents = tester.readFileToString(BUG_ID +"-2" + FS + "pkg1" + FS + "class-use" + FS + "UsedClass.html");
86 int prevIndex = -1;
87 int currentIndex = -1;
88 for (int i = 0; i < TEST2.length; i++) {
89 currentIndex = usePageContents.indexOf(TEST2[i]);
90 System.err.println(TEST2[i] + " at index " + currentIndex);
91 if (currentIndex < prevIndex)
92 throw new Exception(TEST2[i] + " is in the wrong order.");
93 prevIndex = currentIndex;
94 }
95 tester.printSummary();
96 }
98 /**
99 * {@inheritDoc}
100 */
101 public String getBugId() {
102 return BUG_ID;
103 }
105 /**
106 * {@inheritDoc}
107 */
108 public String getBugName() {
109 return getClass().getName();
110 }
111 }