Mon, 16 Sep 2013 14:13:44 +0200
8021112: Spurious unchecked warning reported by javac
6480588: No way to suppress deprecation warnings when implementing deprecated interface
Summary: Fixing DeferredLintHandler configuration, so lint warnings are reported with correct @SuppressWarnings settings
Reviewed-by: jjg, vromero
1 /*
2 * Copyright (c) 2003, 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 4780441 4874845 4978816 8014017
27 * @summary Make sure that when the -private flag is not used, members
28 * inherited from package private class are documented in the child.
29 *
30 * Make sure that when a method inherits documentation from a method
31 * in a non-public class/interface, the non-public class/interface
32 * is not mentioned anywhere (not even in the signature or tree).
33 *
34 * Make sure that when a private interface method with generic parameters
35 * is implemented, the comments can be inherited properly.
36 *
37 * Make sure when no modifier appear in the class signature, the
38 * signature is displayed correctly without extra space at the beginning.
39 * @author jamieh
40 * @library ../lib/
41 * @build JavadocTester TestPrivateClasses
42 * @run main TestPrivateClasses
43 */
45 public class TestPrivateClasses extends JavadocTester {
47 //Test information.
48 private static final String BUG_ID = "4780441-4874845-4978816-8014017";
50 //Javadoc arguments.
51 private static final String[] ARGS1 = new String[] {
52 "-d", BUG_ID + "-1", "-sourcepath", SRC_DIR, "-source", "1.5", "pkg", "pkg2"
53 };
54 private static final String[] ARGS2 = new String[] {
55 "-d", BUG_ID + "-2", "-sourcepath", SRC_DIR, "-private",
56 "-source", "1.5", "pkg", "pkg2"
57 };
59 // Test output when -private flag is not used.
60 private static final String[][] TEST1 = {
61 // Field inheritence from non-public superclass.
62 {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
63 "<a href=\"../pkg/PublicChild.html#fieldInheritedFromParent\">" +
64 "fieldInheritedFromParent</a>"
65 },
67 // Method inheritence from non-public superclass.
68 {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
69 "<a href=\"../pkg/PublicChild.html#methodInheritedFromParent(int)\">" +
70 "methodInheritedFromParent</a>"
71 },
73 // Field inheritence from non-public superinterface.
74 {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
75 "<a href=\"../pkg/PublicInterface.html#fieldInheritedFromInterface\">" +
76 "fieldInheritedFromInterface</a>"
77 },
79 // Method inheritence from non-public superinterface.
80 {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
81 "<a href=\"../pkg/PublicInterface.html#methodInterface(int)\">" +
82 "methodInterface</a>"
83 },
85 // private class does not show up in tree
86 {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
87 "<ul class=\"inheritance\">" + NL + "<li>java.lang.Object</li>" + NL +
88 "<li>" + NL + "<ul class=\"inheritance\">" + NL + "<li>pkg.PublicChild</li>" + NL +
89 "</ul>" + NL + "</li>" + NL + "</ul>"
90 },
92 // Method is documented as though it is declared in the inheriting method.
93 {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
94 "<pre>public void methodInheritedFromParent(int p1)"
95 },
97 //Make sure implemented interfaces from private superclass are inherited
98 {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
99 "<dl>" + NL + "<dt>All Known Implementing Classes:</dt>" + NL +
100 "<dd><a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">" +
101 "PublicChild</a></dd>" + NL + "</dl>"},
103 {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
104 "<dl>" + NL + "<dt>All Implemented Interfaces:</dt>" + NL +
105 "<dd><a href=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">" +
106 "PublicInterface</a></dd>" + NL + "</dl>"},
108 //Generic interface method test.
109 {BUG_ID + "-1" + FS + "pkg2" + FS + "C.html",
110 "This comment should get copied to the implementing class"},
111 };
112 private static final String[][] NEGATED_TEST1 = {
113 // Should not document that a method overrides method from private class.
114 {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
115 "<span class=\"strong\">Overrides:</span>"},
116 // Should not document that a method specified by private interface.
117 {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
118 "<span class=\"strong\">Specified by:</span>"},
119 {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
120 "<span class=\"strong\">Specified by:</span>"},
121 // Should not mention that any documentation was copied.
122 {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
123 "Description copied from"},
124 {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
125 "Description copied from"},
126 // Don't extend private classes or interfaces
127 {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
128 "PrivateParent"},
129 {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
130 "PrivateInterface"},
131 {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
132 "PrivateInterface"},
133 {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
134 "All Superinterfaces"},
135 // Make inherited constant are documented correctly.
136 {BUG_ID + "-1" + FS + "constant-values.html",
137 "PrivateInterface"},
139 //Do not inherit private interface method with generic parameters.
140 //This method has been implemented.
141 {BUG_ID + "-1" + FS + "pkg2" + FS + "C.html",
142 "<span class=\"strong\"><a href=\"../pkg2/I.html#hello(T)\">hello</a></span>"},
143 };
145 // Test output when -private flag is used.
146 private static final String[][] TEST2 = {
147 // Field inheritence from non-public superclass.
148 {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
149 "Fields inherited from class pkg." +
150 "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
151 "PrivateParent</a>"
152 },
153 {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
154 "<a href=\"../pkg/PrivateParent.html#fieldInheritedFromParent\">" +
155 "fieldInheritedFromParent</a>"
156 },
157 // Field inheritence from non-public superinterface.
158 {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
159 "Fields inherited from interface pkg." +
160 "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
161 "PrivateInterface</a>"
162 },
163 {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
164 "<a href=\"../pkg/PrivateInterface.html#fieldInheritedFromInterface\">" +
165 "fieldInheritedFromInterface</a>"
166 },
167 // Method inheritence from non-public superclass.
168 {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
169 "Methods inherited from class pkg." +
170 "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
171 "PrivateParent</a>"
172 },
173 {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
174 "<a href=\"../pkg/PrivateParent.html#methodInheritedFromParent(int)\">" +
175 "methodInheritedFromParent</a>"
176 },
177 // Should document that a method overrides method from private class.
178 {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
179 "<dt><span class=\"strong\">Overrides:</span></dt>" + NL +
180 "<dd><code><a href=\"../pkg/PrivateParent.html#methodOverridenFromParent(char[], int, T, V, java.util.List)\">" +
181 "methodOverridenFromParent</a></code> in class <code>" +
182 "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
183 "PrivateParent</a></code></dd>"},
184 // Should document that a method is specified by private interface.
185 {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
186 "<dt><span class=\"strong\">Specified by:</span></dt>" + NL +
187 "<dd><code><a href=\"../pkg/PrivateInterface.html#methodInterface(int)\">" +
188 "methodInterface</a></code> in interface <code>" +
189 "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
190 "PrivateInterface</a></code></dd>"},
191 // Method inheritence from non-public superinterface.
192 {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
193 "Methods inherited from interface pkg." +
194 "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
195 "PrivateInterface</a>"
196 },
197 {BUG_ID + "-2" + FS + "pkg" + FS + "PrivateInterface.html",
198 "<a href=\"../pkg/PrivateInterface.html#methodInterface(int)\">" +
199 "methodInterface</a>"
200 },
201 // Should mention that any documentation was copied.
202 {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
203 "Description copied from"},
204 // Extend documented private classes or interfaces
205 {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
206 "extends"},
207 {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
208 "extends"},
209 {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
210 "All Superinterfaces"},
212 //Make sure implemented interfaces from private superclass are inherited
213 {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
214 "<dl>" + NL + "<dt>All Known Implementing Classes:</dt>" + NL +
215 "<dd><a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
216 "PrivateParent</a>, " +
217 "<a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">PublicChild" +
218 "</a></dd>" + NL + "</dl>"},
220 {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
221 "<dl>" + NL + "<dt>All Implemented Interfaces:</dt>" + NL +
222 "<dd><a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
223 "PrivateInterface</a>, " +
224 "<a href=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">" +
225 "PublicInterface</a></dd>" + NL + "</dl>"},
227 //Since private flag is used, we can document that private interface method
228 //with generic parameters has been implemented.
229 {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html",
230 "<span class=\"strong\">Description copied from interface: <code>" +
231 "<a href=\"../pkg2/I.html#hello(T)\">I</a></code></span>"},
233 {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html",
234 "<dt><span class=\"strong\">Specified by:</span></dt>" + NL +
235 "<dd><code><a href=\"../pkg2/I.html#hello(T)\">hello</a></code>" +
236 " in interface <code>" +
237 "<a href=\"../pkg2/I.html\" title=\"interface in pkg2\">I</a>" +
238 "<java.lang.String></code></dd>"},
240 //Make sure when no modifier appear in the class signature, the
241 //signature is displayed correctly without extra space at the beginning.
242 {BUG_ID + "-2" + FS + "pkg" + FS + "PrivateParent.html",
243 "<pre>class <span class=\"strong\">PrivateParent</span>"},
245 {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
246 "<pre>public class <span class=\"strong\">PublicChild</span>"},
247 };
248 private static final String[][] NEGATED_TEST2 = {
249 {BUG_ID + "-2" + FS + "pkg" + FS + "PrivateParent.html",
250 "<pre> class <span class=\"strong\">PrivateParent</span>"},
251 };
253 /**
254 * The entry point of the test.
255 * @param args the array of command line arguments.
256 */
257 public static void main(String[] args) {
258 TestPrivateClasses tester = new TestPrivateClasses();
259 run(tester, ARGS1, TEST1, NEGATED_TEST1);
260 run(tester, ARGS2, TEST2, NEGATED_TEST2);
261 tester.printSummary();
262 }
264 /**
265 * {@inheritDoc}
266 */
267 public String getBugId() {
268 return BUG_ID;
269 }
271 /**
272 * {@inheritDoc}
273 */
274 public String getBugName() {
275 return getClass().getName();
276 }
277 }