Wed, 18 Sep 2013 22:47:06 -0700
8024096: some javadoc tests may contain false positive results
Reviewed-by: jjg
1 /*
2 * Copyright (c) 2013, 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 8005091 8009686
27 * @summary Make sure that type annotations are displayed correctly
28 * @author Bhavesh Patel
29 * @library ../lib/
30 * @build JavadocTester TestTypeAnnotations
31 * @run main TestTypeAnnotations
32 */
34 public class TestTypeAnnotations extends JavadocTester {
36 //Test information.
37 private static final String BUG_ID = "8005091-8009686";
39 //Javadoc arguments.
40 private static final String[] ARGS = new String[] {
41 "-d", BUG_ID, "-sourcepath", SRC_DIR, "-private", "typeannos"
42 };
44 //Input for string search tests.
45 private static final String[][] NEGATED_TEST = NO_TEST;
46 private static final String[][] TEST = {
47 // Test for type annotations on Class Extends (ClassExtends.java).
48 {BUG_ID + FS + "typeannos" + FS + "MyClass.html",
49 "extends <a href=\"../typeannos/ClassExtA.html\" title=\"annotation " +
50 "in typeannos\">@ClassExtA</a> <a href=\"../typeannos/ParameterizedClass.html\" " +
51 "title=\"class in typeannos\">ParameterizedClass</a><<a href=\"" +
52 "../typeannos/ClassExtB.html\" title=\"annotation in typeannos\">" +
53 "@ClassExtB</a> java.lang.String>"
54 },
55 {BUG_ID + FS + "typeannos" + FS + "MyClass.html",
56 "implements <a href=\"../typeannos/ClassExtB.html\" title=\"" +
57 "annotation in typeannos\">@ClassExtB</a> java.lang.CharSequence, " +
58 "<a href=\"../typeannos/ClassExtA.html\" title=\"annotation in " +
59 "typeannos\">@ClassExtA</a> <a href=\"../typeannos/ParameterizedInterface.html\" " +
60 "title=\"interface in typeannos\">ParameterizedInterface</a><" +
61 "<a href=\"../typeannos/ClassExtB.html\" title=\"annotation in " +
62 "typeannos\">@ClassExtB</a> java.lang.String></pre>"
63 },
64 {BUG_ID + FS + "typeannos" + FS + "MyInterface.html",
65 "extends <a href=\"../typeannos/ClassExtA.html\" title=\"annotation " +
66 "in typeannos\">@ClassExtA</a> <a href=\"../typeannos/" +
67 "ParameterizedInterface.html\" title=\"interface in typeannos\">" +
68 "ParameterizedInterface</a><<a href=\"../typeannos/ClassExtA.html\" " +
69 "title=\"annotation in typeannos\">@ClassExtA</a> java.lang.String>, " +
70 "<a href=\"../typeannos/ClassExtB.html\" title=\"annotation in " +
71 "typeannos\">@ClassExtB</a> java.lang.CharSequence</pre>"
72 },
74 // Test for type annotations on Class Parameters (ClassParameters.java).
75 {BUG_ID + FS + "typeannos" + FS + "ExtendsBound.html",
76 "class <span class=\"strong\">ExtendsBound<K extends <a " +
77 "href=\"../typeannos/ClassParamA.html\" title=\"annotation in " +
78 "typeannos\">@ClassParamA</a> java.lang.String></span>"
79 },
80 {BUG_ID + FS + "typeannos" + FS + "ExtendsGeneric.html",
81 "<pre>class <span class=\"strong\">ExtendsGeneric<K extends " +
82 "<a href=\"../typeannos/ClassParamA.html\" title=\"annotation in " +
83 "typeannos\">@ClassParamA</a> <a href=\"../typeannos/Unannotated.html\" " +
84 "title=\"class in typeannos\">Unannotated</a><<a href=\"" +
85 "../typeannos/ClassParamB.html\" title=\"annotation in typeannos\">" +
86 "@ClassParamB</a> java.lang.String>></span>"
87 },
88 {BUG_ID + FS + "typeannos" + FS + "TwoBounds.html",
89 "<pre>class <span class=\"strong\">TwoBounds<K extends <a href=\"" +
90 "../typeannos/ClassParamA.html\" title=\"annotation in typeannos\">" +
91 "@ClassParamA</a> java.lang.String,V extends <a href=\"../typeannos/" +
92 "ClassParamB.html\" title=\"annotation in typeannos\">@ClassParamB" +
93 "</a> java.lang.String></span>"
94 },
95 {BUG_ID + FS + "typeannos" + FS + "Complex1.html",
96 "class <span class=\"strong\">Complex1<K extends <a href=\"../" +
97 "typeannos/ClassParamA.html\" title=\"annotation in typeannos\">" +
98 "@ClassParamA</a> java.lang.String & java.lang.Runnable></span>"
99 },
100 {BUG_ID + FS + "typeannos" + FS + "Complex2.html",
101 "class <span class=\"strong\">Complex2<K extends java.lang." +
102 "String & <a href=\"../typeannos/ClassParamB.html\" title=\"" +
103 "annotation in typeannos\">@ClassParamB</a> java.lang.Runnable></span>"
104 },
105 {BUG_ID + FS + "typeannos" + FS + "ComplexBoth.html",
106 "class <span class=\"strong\">ComplexBoth<K extends <a href=\"" +
107 "../typeannos/ClassParamA.html\" title=\"annotation in typeannos\"" +
108 ">@ClassParamA</a> java.lang.String & <a href=\"../typeannos/" +
109 "ClassParamA.html\" title=\"annotation in typeannos\">@ClassParamA" +
110 "</a> java.lang.Runnable></span>"
111 },
113 // Test for type annotations on fields (Fields.java).
114 {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html",
115 "<pre><a href=\"../typeannos/Parameterized.html\" title=\"class in " +
116 "typeannos\">Parameterized</a><<a href=\"../typeannos/FldA.html\" " +
117 "title=\"annotation in typeannos\">@FldA</a> java.lang.String,<a " +
118 "href=\"../typeannos/FldB.html\" title=\"annotation in typeannos\">" +
119 "@FldB</a> java.lang.String> bothTypeArgs</pre>"
120 },
121 {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html",
122 "<pre><a href=\"../typeannos/FldA.html\" title=\"annotation in " +
123 "typeannos\">@FldA</a> java.lang.String <a href=\"../typeannos/" +
124 "FldB.html\" title=\"annotation in typeannos\">@FldB</a> [] " +
125 "array1Deep</pre>"
126 },
127 {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html",
128 "<pre>java.lang.String[] <a href=\"../typeannos/FldB.html\" " +
129 "title=\"annotation in typeannos\">@FldB</a> [] array2SecondOld</pre>"
130 },
131 {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html",
132 "<pre><a href=\"../typeannos/FldD.html\" title=\"annotation in " +
133 "typeannos\">@FldD</a> java.lang.String <a href=\"../typeannos/" +
134 "FldC.html\" title=\"annotation in typeannos\">@FldC</a> <a href=\"" +
135 "../typeannos/FldA.html\" title=\"annotation in typeannos\">@FldA" +
136 "</a> [] <a href=\"../typeannos/FldC.html\" title=\"annotation in " +
137 "typeannos\">@FldC</a> <a href=\"../typeannos/FldB.html\" title=\"" +
138 "annotation in typeannos\">@FldB</a> [] array2Deep</pre>"
139 },
140 {BUG_ID + FS + "typeannos" + FS + "ModifiedScoped.html",
141 "<pre>public final <a href=\"../typeannos/Parameterized.html\" " +
142 "title=\"class in typeannos\">Parameterized</a><<a href=\"../" +
143 "typeannos/FldA.html\" title=\"annotation in typeannos\">@FldA</a> " +
144 "<a href=\"../typeannos/Parameterized.html\" title=\"class in " +
145 "typeannos\">Parameterized</a><<a href=\"../typeannos/FldA.html\" " +
146 "title=\"annotation in typeannos\">@FldA</a> java.lang.String,<a " +
147 "href=\"../typeannos/FldB.html\" title=\"annotation in typeannos\">" +
148 "@FldB</a> java.lang.String>,<a href=\"../typeannos/FldB.html\" " +
149 "title=\"annotation in typeannos\">@FldB</a> java.lang.String> " +
150 "nestedParameterized</pre>"
151 },
152 {BUG_ID + FS + "typeannos" + FS + "ModifiedScoped.html",
153 "<pre>public final <a href=\"../typeannos/FldA.html\" " +
154 "title=\"annotation in typeannos\">@FldA</a> java.lang.String[][] " +
155 "array2</pre>"
156 },
158 // Test for type annotations on method return types (MethodReturnType.java).
159 {BUG_ID + FS + "typeannos" + FS + "MtdDefaultScope.html",
160 "<pre>public <T> <a href=\"../typeannos/MRtnA.html\" " +
161 "title=\"annotation in typeannos\">@MRtnA</a> java.lang.String" +
162 " method()</pre>"
163 },
164 {BUG_ID + FS + "typeannos" + FS + "MtdDefaultScope.html",
165 "<pre><a href=\"../typeannos/MRtnA.html\" title=\"annotation in " +
166 "typeannos\">@MRtnA</a> java.lang.String <a href=\"../typeannos/" +
167 "MRtnA.html\" title=\"annotation in typeannos\">@MRtnA</a> [] <a " +
168 "href=\"../typeannos/MRtnB.html\" title=\"annotation in typeannos\">" +
169 "@MRtnB</a> [] array2Deep()</pre>"
170 },
171 {BUG_ID + FS + "typeannos" + FS + "MtdDefaultScope.html",
172 "<pre><a href=\"../typeannos/MRtnA.html\" title=\"annotation in " +
173 "typeannos\">@MRtnA</a> java.lang.String[][] array2()</pre>"
174 },
175 {BUG_ID + FS + "typeannos" + FS + "MtdModifiedScoped.html",
176 "<pre>public final <a href=\"../typeannos/MtdParameterized.html\" " +
177 "title=\"class in typeannos\">MtdParameterized</a><<a href=\"../" +
178 "typeannos/MRtnA.html\" title=\"annotation in typeannos\">@MRtnA</a> " +
179 "<a href=\"../typeannos/MtdParameterized.html\" title=\"class in " +
180 "typeannos\">MtdParameterized</a><<a href=\"../typeannos/MRtnA." +
181 "html\" title=\"annotation in typeannos\">@MRtnA</a> java.lang." +
182 "String,<a href=\"../typeannos/MRtnB.html\" title=\"annotation in " +
183 "typeannos\">@MRtnB</a> java.lang.String>,<a href=\"../typeannos/" +
184 "MRtnB.html\" title=\"annotation in typeannos\">@MRtnB</a> java." +
185 "lang.String> nestedMtdParameterized()</pre>"
186 },
188 // Test for type annotations on method type parameters (MethodTypeParameters.java).
189 {BUG_ID + FS + "typeannos" + FS + "UnscopedUnmodified.html",
190 "<pre><K extends <a href=\"../typeannos/MTyParamA.html\" title=\"" +
191 "annotation in typeannos\">@MTyParamA</a> java.lang.String>" +
192 " void methodExtends()</pre>"
193 },
194 {BUG_ID + FS + "typeannos" + FS + "UnscopedUnmodified.html",
195 "<pre><K extends <a href=\"../typeannos/MTyParamA.html\" title=\"" +
196 "annotation in typeannos\">@MTyParamA</a> <a href=\"../typeannos/" +
197 "MtdTyParameterized.html\" title=\"class in typeannos\">" +
198 "MtdTyParameterized</a><<a href=\"../typeannos/MTyParamB.html\" " +
199 "title=\"annotation in typeannos\">@MTyParamB</a> java.lang.String" +
200 ">> void nestedExtends()</pre>"
201 },
202 {BUG_ID + FS + "typeannos" + FS + "PublicModifiedMethods.html",
203 "<pre>public final <K extends <a href=\"../typeannos/" +
204 "MTyParamA.html\" title=\"annotation in typeannos\">@MTyParamA</a> " +
205 "java.lang.String> void methodExtends()</pre>"
206 },
207 {BUG_ID + FS + "typeannos" + FS + "PublicModifiedMethods.html",
208 "<pre>public final <K extends <a href=\"../typeannos/" +
209 "MTyParamA.html\" title=\"annotation in typeannos\">@MTyParamA</a> " +
210 "java.lang.String,V extends <a href=\"../typeannos/MTyParamA.html\" " +
211 "title=\"annotation in typeannos\">@MTyParamA</a> <a href=\"../" +
212 "typeannos/MtdTyParameterized.html\" title=\"class in typeannos\">" +
213 "MtdTyParameterized</a><<a href=\"../typeannos/MTyParamB.html\" " +
214 "title=\"annotation in typeannos\">@MTyParamB</a> java.lang.String" +
215 ">> void dual()</pre>"
216 },
218 // Test for type annotations on parameters (Parameters.java).
219 {BUG_ID + FS + "typeannos" + FS + "Parameters.html",
220 "<pre>void unannotated(<a href=\"../typeannos/" +
221 "ParaParameterized.html\" title=\"class in typeannos\">" +
222 "ParaParameterized</a><java.lang.String,java.lang.String>" +
223 " a)</pre>"
224 },
225 {BUG_ID + FS + "typeannos" + FS + "Parameters.html",
226 "<pre>void nestedParaParameterized(<a href=\"../typeannos/" +
227 "ParaParameterized.html\" title=\"class in typeannos\">" +
228 "ParaParameterized</a><<a href=\"../typeannos/ParamA.html\" " +
229 "title=\"annotation in typeannos\">@ParamA</a> <a href=\"../" +
230 "typeannos/ParaParameterized.html\" title=\"class in typeannos\">" +
231 "ParaParameterized</a><<a href=\"../typeannos/ParamA.html\" " +
232 "title=\"annotation in typeannos\">@ParamA</a> java.lang.String," +
233 "<a href=\"../typeannos/ParamB.html\" title=\"annotation in " +
234 "typeannos\">@ParamB</a> java.lang.String>,<a href=\"../" +
235 "typeannos/ParamB.html\" title=\"annotation in typeannos\">@ParamB" +
236 "</a> java.lang.String> a)</pre>"
237 },
238 {BUG_ID + FS + "typeannos" + FS + "Parameters.html",
239 "<pre>void array2Deep(<a href=\"../typeannos/ParamA.html\" " +
240 "title=\"annotation in typeannos\">@ParamA</a> java.lang.String " +
241 "<a href=\"../typeannos/ParamA.html\" title=\"annotation in " +
242 "typeannos\">@ParamA</a> [] <a href=\"../typeannos/ParamB.html\" " +
243 "title=\"annotation in typeannos\">@ParamB</a> [] a)</pre>"
244 },
246 // Test for type annotations on throws (Throws.java).
247 {BUG_ID + FS + "typeannos" + FS + "ThrDefaultUnmodified.html",
248 "<pre>void oneException()" + NL +
249 " throws <a href=\"../typeannos/ThrA.html\" title=\"" +
250 "annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>"
251 },
252 {BUG_ID + FS + "typeannos" + FS + "ThrDefaultUnmodified.html",
253 "<pre>void twoExceptions()" + NL +
254 " throws <a href=\"../typeannos/ThrA.html\" title=\"" +
255 "annotation in typeannos\">@ThrA</a> java.lang.RuntimeException," + NL +
256 " <a href=\"../typeannos/ThrA.html\" title=\"" +
257 "annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>"
258 },
259 {BUG_ID + FS + "typeannos" + FS + "ThrPublicModified.html",
260 "<pre>public final void oneException(java.lang.String a)" + NL +
261 " throws <a href=\"../typeannos/ThrA.html\" " +
262 "title=\"annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>"
263 },
264 {BUG_ID + FS + "typeannos" + FS + "ThrPublicModified.html",
265 "<pre>public final void twoExceptions(java.lang.String a)" + NL +
266 " throws <a href=\"../typeannos/ThrA.html\" " +
267 "title=\"annotation in typeannos\">@ThrA</a> java.lang.RuntimeException," + NL +
268 " <a href=\"../typeannos/ThrA.html\" " +
269 "title=\"annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>"
270 },
271 {BUG_ID + FS + "typeannos" + FS + "ThrWithValue.html",
272 "<pre>void oneException()" + NL +
273 " throws <a href=\"../typeannos/ThrB.html\" title=\"" +
274 "annotation in typeannos\">@ThrB</a>(<a href=\"../typeannos/" +
275 "ThrB.html#value()\">value</a>=\"m\") java.lang.Exception</pre>"
276 },
277 {BUG_ID + FS + "typeannos" + FS + "ThrWithValue.html",
278 "<pre>void twoExceptions()" + NL +
279 " throws <a href=\"../typeannos/ThrB.html\" title=\"" +
280 "annotation in typeannos\">@ThrB</a>(<a href=\"../typeannos/" +
281 "ThrB.html#value()\">value</a>=\"m\") java.lang.RuntimeException," + NL +
282 " <a href=\"../typeannos/ThrA.html\" title=\"" +
283 "annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>"
284 },
286 // Test for type annotations on type parameters (TypeParameters.java).
287 {BUG_ID + FS + "typeannos" + FS + "TestMethods.html",
288 "<pre><K,V extends <a href=\"../typeannos/TyParaA.html\" title=\"" +
289 "annotation in typeannos\">@TyParaA</a> java.lang.String> " +
290 "void secondAnnotated()</pre>"
291 },
293 // Test for type annotations on wildcard type (Wildcards.java).
294 {BUG_ID + FS + "typeannos" + FS + "BoundTest.html",
295 "<pre>void wcExtends(<a href=\"../typeannos/MyList.html\" " +
296 "title=\"class in typeannos\">MyList</a><? extends <a href=\"" +
297 "../typeannos/WldA.html\" title=\"annotation in typeannos\">@WldA" +
298 "</a> java.lang.String> l)</pre>"
299 },
300 {BUG_ID + FS + "typeannos" + FS + "BoundTest.html",
301 "<pre><a href=\"../typeannos/MyList.html\" title=\"class in " +
302 "typeannos\">MyList</a><? super <a href=\"../typeannos/WldA.html\" " +
303 "title=\"annotation in typeannos\">@WldA</a> java.lang.String>" +
304 " returnWcSuper()</pre>"
305 },
306 {BUG_ID + FS + "typeannos" + FS + "BoundWithValue.html",
307 "<pre>void wcSuper(<a href=\"../typeannos/MyList.html\" title=\"" +
308 "class in typeannos\">MyList</a><? super <a href=\"../typeannos/" +
309 "WldB.html\" title=\"annotation in typeannos\">@WldB</a>(<a href=\"" +
310 "../typeannos/WldB.html#value()\">value</a>=\"m\") java.lang." +
311 "String> l)</pre>"
312 },
313 {BUG_ID + FS + "typeannos" + FS + "BoundWithValue.html",
314 "<pre><a href=\"../typeannos/MyList.html\" title=\"class in " +
315 "typeannos\">MyList</a><? extends <a href=\"../typeannos/WldB." +
316 "html\" title=\"annotation in typeannos\">@WldB</a>(<a href=\"../" +
317 "typeannos/WldB.html#value()\">value</a>=\"m\") java.lang.String" +
318 "> returnWcExtends()</pre>"
319 },
321 // Test for receiver annotations (Receivers.java).
322 {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html",
323 "<pre>void withException(<a href=\"../typeannos/RcvrA.html\" " +
324 "title=\"annotation in typeannos\">@RcvrA</a> " +
325 "DefaultUnmodified this)" + NL + " throws java." +
326 "lang.Exception</pre>"
327 },
328 {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html",
329 "<pre>java.lang.String nonVoid(<a href=\"../typeannos/RcvrA." +
330 "html\" title=\"annotation in typeannos\">@RcvrA</a> <a href=\"../" +
331 "typeannos/RcvrB.html\" title=\"annotation in typeannos\">@RcvrB" +
332 "</a>(<a href=\"../typeannos/RcvrB.html#value()\">value</a>=\"m\")" +
333 " DefaultUnmodified this)</pre>"
334 },
335 {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html",
336 "<pre><T extends java.lang.Runnable> void accept(" +
337 "<a href=\"../typeannos/RcvrA.html\" title=\"annotation in " +
338 "typeannos\">@RcvrA</a> DefaultUnmodified this," + NL +
339 " T r)" + NL +
340 " throws java.lang.Exception</pre>"
341 },
342 {BUG_ID + FS + "typeannos" + FS + "PublicModified.html",
343 "<pre>public final java.lang.String nonVoid(<a href=\"" +
344 "../typeannos/RcvrA.html\" title=\"annotation in typeannos\">" +
345 "@RcvrA</a> PublicModified this)</pre>"
346 },
347 {BUG_ID + FS + "typeannos" + FS + "PublicModified.html",
348 "<pre>public final <T extends java.lang.Runnable> " +
349 "void accept(<a href=\"../typeannos/RcvrA.html\" title=\"" +
350 "annotation in typeannos\">@RcvrA</a> PublicModified this," + NL +
351 " T r)" + NL +
352 " throws java.lang.Exception</pre>"
353 },
354 {BUG_ID + FS + "typeannos" + FS + "WithValue.html",
355 "<pre><T extends java.lang.Runnable> void accept(" +
356 "<a href=\"../typeannos/RcvrB.html\" title=\"annotation in " +
357 "typeannos\">@RcvrB</a>(<a href=\"../typeannos/RcvrB.html#value()\">" +
358 "value</a>=\"m\") WithValue this," + NL +
359 " T r)" + NL +
360 " throws java.lang.Exception</pre>"
361 },
362 {BUG_ID + FS + "typeannos" + FS + "WithFinal.html",
363 "<pre>java.lang.String nonVoid(<a href=\"../typeannos/RcvrB." +
364 "html\" title=\"annotation in typeannos\">@RcvrB</a>(<a href=\"../" +
365 "typeannos/RcvrB.html#value()\">value</a>=\"m\") WithFinal" +
366 " this)</pre>"
367 },
368 {BUG_ID + FS + "typeannos" + FS + "WithBody.html",
369 "<pre>void field(<a href=\"../typeannos/RcvrA.html\" title=\"" +
370 "annotation in typeannos\">@RcvrA</a> WithBody this)</pre>"
371 },
372 {BUG_ID + FS + "typeannos" + FS + "Generic2.html",
373 "<pre>void test2(<a href=\"../typeannos/RcvrA.html\" title=\"" +
374 "annotation in typeannos\">@RcvrA</a> Generic2<X> this)</pre>"
375 }
376 };
378 /**
379 * The entry point of the test.
380 * @param args the array of command line arguments.
381 */
382 public static void main(String[] args) {
383 TestTypeAnnotations tester = new TestTypeAnnotations();
384 run(tester, ARGS, TEST, NEGATED_TEST);
385 tester.printSummary();
386 }
388 /**
389 * {@inheritDoc}
390 */
391 public String getBugId() {
392 return BUG_ID;
393 }
395 /**
396 * {@inheritDoc}
397 */
398 public String getBugName() {
399 return getClass().getName();
400 }
401 }