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
duke@1 | 1 | /* |
bpatel@1858 | 2 | * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@1 | 7 | * published by the Free Software Foundation. |
duke@1 | 8 | * |
duke@1 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 13 | * accompanied this code). |
duke@1 | 14 | * |
duke@1 | 15 | * You should have received a copy of the GNU General Public License version |
duke@1 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 18 | * |
ohair@554 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 20 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 21 | * questions. |
duke@1 | 22 | */ |
duke@1 | 23 | |
duke@1 | 24 | /* |
duke@1 | 25 | * @test |
bpatel@1858 | 26 | * @bug 4780441 4874845 4978816 8014017 |
duke@1 | 27 | * @summary Make sure that when the -private flag is not used, members |
duke@1 | 28 | * inherited from package private class are documented in the child. |
duke@1 | 29 | * |
duke@1 | 30 | * Make sure that when a method inherits documentation from a method |
duke@1 | 31 | * in a non-public class/interface, the non-public class/interface |
duke@1 | 32 | * is not mentioned anywhere (not even in the signature or tree). |
duke@1 | 33 | * |
duke@1 | 34 | * Make sure that when a private interface method with generic parameters |
duke@1 | 35 | * is implemented, the comments can be inherited properly. |
bpatel@1858 | 36 | * |
bpatel@1858 | 37 | * Make sure when no modifier appear in the class signature, the |
bpatel@1858 | 38 | * signature is displayed correctly without extra space at the beginning. |
duke@1 | 39 | * @author jamieh |
duke@1 | 40 | * @library ../lib/ |
bpatel@1858 | 41 | * @build JavadocTester TestPrivateClasses |
duke@1 | 42 | * @run main TestPrivateClasses |
duke@1 | 43 | */ |
duke@1 | 44 | |
duke@1 | 45 | public class TestPrivateClasses extends JavadocTester { |
duke@1 | 46 | |
duke@1 | 47 | //Test information. |
bpatel@1858 | 48 | private static final String BUG_ID = "4780441-4874845-4978816-8014017"; |
duke@1 | 49 | |
duke@1 | 50 | //Javadoc arguments. |
duke@1 | 51 | private static final String[] ARGS1 = new String[] { |
duke@1 | 52 | "-d", BUG_ID + "-1", "-sourcepath", SRC_DIR, "-source", "1.5", "pkg", "pkg2" |
duke@1 | 53 | }; |
duke@1 | 54 | private static final String[] ARGS2 = new String[] { |
duke@1 | 55 | "-d", BUG_ID + "-2", "-sourcepath", SRC_DIR, "-private", |
duke@1 | 56 | "-source", "1.5", "pkg", "pkg2" |
duke@1 | 57 | }; |
duke@1 | 58 | |
duke@1 | 59 | // Test output when -private flag is not used. |
duke@1 | 60 | private static final String[][] TEST1 = { |
duke@1 | 61 | // Field inheritence from non-public superclass. |
duke@1 | 62 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 63 | "<a href=\"../pkg/PublicChild.html#fieldInheritedFromParent\">" + |
bpatel@766 | 64 | "fieldInheritedFromParent</a>" |
duke@1 | 65 | }, |
duke@1 | 66 | |
duke@1 | 67 | // Method inheritence from non-public superclass. |
duke@1 | 68 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 69 | "<a href=\"../pkg/PublicChild.html#methodInheritedFromParent(int)\">" + |
bpatel@766 | 70 | "methodInheritedFromParent</a>" |
duke@1 | 71 | }, |
duke@1 | 72 | |
duke@1 | 73 | // Field inheritence from non-public superinterface. |
duke@1 | 74 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
bpatel@766 | 75 | "<a href=\"../pkg/PublicInterface.html#fieldInheritedFromInterface\">" + |
bpatel@766 | 76 | "fieldInheritedFromInterface</a>" |
duke@1 | 77 | }, |
duke@1 | 78 | |
duke@1 | 79 | // Method inheritence from non-public superinterface. |
duke@1 | 80 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
bpatel@766 | 81 | "<a href=\"../pkg/PublicInterface.html#methodInterface(int)\">" + |
bpatel@766 | 82 | "methodInterface</a>" |
duke@1 | 83 | }, |
duke@1 | 84 | |
duke@1 | 85 | // private class does not show up in tree |
duke@1 | 86 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 87 | "<ul class=\"inheritance\">" + NL + "<li>java.lang.Object</li>" + NL + |
bpatel@766 | 88 | "<li>" + NL + "<ul class=\"inheritance\">" + NL + "<li>pkg.PublicChild</li>" + NL + |
bpatel@766 | 89 | "</ul>" + NL + "</li>" + NL + "</ul>" |
duke@1 | 90 | }, |
duke@1 | 91 | |
duke@1 | 92 | // Method is documented as though it is declared in the inheriting method. |
duke@1 | 93 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 94 | "<pre>public void methodInheritedFromParent(int p1)" |
duke@1 | 95 | }, |
duke@1 | 96 | |
duke@1 | 97 | //Make sure implemented interfaces from private superclass are inherited |
duke@1 | 98 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
bpatel@766 | 99 | "<dl>" + NL + "<dt>All Known Implementing Classes:</dt>" + NL + |
bpatel@766 | 100 | "<dd><a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">" + |
bpatel@766 | 101 | "PublicChild</a></dd>" + NL + "</dl>"}, |
duke@1 | 102 | |
duke@1 | 103 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 104 | "<dl>" + NL + "<dt>All Implemented Interfaces:</dt>" + NL + |
bpatel@766 | 105 | "<dd><a href=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">" + |
bpatel@766 | 106 | "PublicInterface</a></dd>" + NL + "</dl>"}, |
duke@1 | 107 | |
duke@1 | 108 | //Generic interface method test. |
duke@1 | 109 | {BUG_ID + "-1" + FS + "pkg2" + FS + "C.html", |
duke@1 | 110 | "This comment should get copied to the implementing class"}, |
duke@1 | 111 | }; |
duke@1 | 112 | private static final String[][] NEGATED_TEST1 = { |
duke@1 | 113 | // Should not document that a method overrides method from private class. |
duke@1 | 114 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@1935 | 115 | "<span class=\"strong\">Overrides:</span>"}, |
duke@1 | 116 | // Should not document that a method specified by private interface. |
duke@1 | 117 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@1935 | 118 | "<span class=\"strong\">Specified by:</span>"}, |
duke@1 | 119 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
bpatel@1935 | 120 | "<span class=\"strong\">Specified by:</span>"}, |
duke@1 | 121 | // Should not mention that any documentation was copied. |
duke@1 | 122 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 123 | "Description copied from"}, |
duke@1 | 124 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 125 | "Description copied from"}, |
duke@1 | 126 | // Don't extend private classes or interfaces |
duke@1 | 127 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 128 | "PrivateParent"}, |
duke@1 | 129 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 130 | "PrivateInterface"}, |
duke@1 | 131 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 132 | "PrivateInterface"}, |
duke@1 | 133 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 134 | "All Superinterfaces"}, |
duke@1 | 135 | // Make inherited constant are documented correctly. |
duke@1 | 136 | {BUG_ID + "-1" + FS + "constant-values.html", |
duke@1 | 137 | "PrivateInterface"}, |
duke@1 | 138 | |
duke@1 | 139 | //Do not inherit private interface method with generic parameters. |
duke@1 | 140 | //This method has been implemented. |
duke@1 | 141 | {BUG_ID + "-1" + FS + "pkg2" + FS + "C.html", |
bpatel@1935 | 142 | "<span class=\"strong\"><a href=\"../pkg2/I.html#hello(T)\">hello</a></span>"}, |
duke@1 | 143 | }; |
duke@1 | 144 | |
duke@1 | 145 | // Test output when -private flag is used. |
duke@1 | 146 | private static final String[][] TEST2 = { |
duke@1 | 147 | // Field inheritence from non-public superclass. |
duke@1 | 148 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 149 | "Fields inherited from class pkg." + |
bpatel@766 | 150 | "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" + |
bpatel@766 | 151 | "PrivateParent</a>" |
duke@1 | 152 | }, |
duke@1 | 153 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 154 | "<a href=\"../pkg/PrivateParent.html#fieldInheritedFromParent\">" + |
bpatel@766 | 155 | "fieldInheritedFromParent</a>" |
duke@1 | 156 | }, |
duke@1 | 157 | // Field inheritence from non-public superinterface. |
duke@1 | 158 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", |
bpatel@766 | 159 | "Fields inherited from interface pkg." + |
bpatel@766 | 160 | "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" + |
bpatel@766 | 161 | "PrivateInterface</a>" |
duke@1 | 162 | }, |
duke@1 | 163 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", |
bpatel@766 | 164 | "<a href=\"../pkg/PrivateInterface.html#fieldInheritedFromInterface\">" + |
bpatel@766 | 165 | "fieldInheritedFromInterface</a>" |
duke@1 | 166 | }, |
duke@1 | 167 | // Method inheritence from non-public superclass. |
duke@1 | 168 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 169 | "Methods inherited from class pkg." + |
bpatel@766 | 170 | "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" + |
bpatel@766 | 171 | "PrivateParent</a>" |
duke@1 | 172 | }, |
duke@1 | 173 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 174 | "<a href=\"../pkg/PrivateParent.html#methodInheritedFromParent(int)\">" + |
bpatel@766 | 175 | "methodInheritedFromParent</a>" |
duke@1 | 176 | }, |
duke@1 | 177 | // Should document that a method overrides method from private class. |
duke@1 | 178 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@1935 | 179 | "<dt><span class=\"strong\">Overrides:</span></dt>" + NL + |
bpatel@766 | 180 | "<dd><code><a href=\"../pkg/PrivateParent.html#methodOverridenFromParent(char[], int, T, V, java.util.List)\">" + |
bpatel@766 | 181 | "methodOverridenFromParent</a></code> in class <code>" + |
bpatel@766 | 182 | "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" + |
bpatel@766 | 183 | "PrivateParent</a></code></dd>"}, |
duke@1 | 184 | // Should document that a method is specified by private interface. |
duke@1 | 185 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@1935 | 186 | "<dt><span class=\"strong\">Specified by:</span></dt>" + NL + |
bpatel@766 | 187 | "<dd><code><a href=\"../pkg/PrivateInterface.html#methodInterface(int)\">" + |
bpatel@766 | 188 | "methodInterface</a></code> in interface <code>" + |
bpatel@766 | 189 | "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" + |
bpatel@766 | 190 | "PrivateInterface</a></code></dd>"}, |
duke@1 | 191 | // Method inheritence from non-public superinterface. |
duke@1 | 192 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", |
bpatel@766 | 193 | "Methods inherited from interface pkg." + |
bpatel@766 | 194 | "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" + |
bpatel@766 | 195 | "PrivateInterface</a>" |
duke@1 | 196 | }, |
duke@1 | 197 | {BUG_ID + "-2" + FS + "pkg" + FS + "PrivateInterface.html", |
bpatel@766 | 198 | "<a href=\"../pkg/PrivateInterface.html#methodInterface(int)\">" + |
bpatel@766 | 199 | "methodInterface</a>" |
duke@1 | 200 | }, |
duke@1 | 201 | // Should mention that any documentation was copied. |
duke@1 | 202 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 203 | "Description copied from"}, |
duke@1 | 204 | // Extend documented private classes or interfaces |
duke@1 | 205 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 206 | "extends"}, |
duke@1 | 207 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 208 | "extends"}, |
duke@1 | 209 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 210 | "All Superinterfaces"}, |
duke@1 | 211 | |
duke@1 | 212 | //Make sure implemented interfaces from private superclass are inherited |
duke@1 | 213 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", |
bpatel@766 | 214 | "<dl>" + NL + "<dt>All Known Implementing Classes:</dt>" + NL + |
bpatel@766 | 215 | "<dd><a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" + |
bpatel@766 | 216 | "PrivateParent</a>, " + |
bpatel@766 | 217 | "<a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">PublicChild" + |
bpatel@766 | 218 | "</a></dd>" + NL + "</dl>"}, |
duke@1 | 219 | |
duke@1 | 220 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 221 | "<dl>" + NL + "<dt>All Implemented Interfaces:</dt>" + NL + |
bpatel@766 | 222 | "<dd><a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" + |
bpatel@766 | 223 | "PrivateInterface</a>, " + |
bpatel@766 | 224 | "<a href=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">" + |
bpatel@766 | 225 | "PublicInterface</a></dd>" + NL + "</dl>"}, |
duke@1 | 226 | |
duke@1 | 227 | //Since private flag is used, we can document that private interface method |
duke@1 | 228 | //with generic parameters has been implemented. |
duke@1 | 229 | {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html", |
bpatel@1935 | 230 | "<span class=\"strong\">Description copied from interface: <code>" + |
bpatel@1935 | 231 | "<a href=\"../pkg2/I.html#hello(T)\">I</a></code></span>"}, |
duke@1 | 232 | |
duke@1 | 233 | {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html", |
bpatel@1935 | 234 | "<dt><span class=\"strong\">Specified by:</span></dt>" + NL + |
bpatel@766 | 235 | "<dd><code><a href=\"../pkg2/I.html#hello(T)\">hello</a></code>" + |
bpatel@766 | 236 | " in interface <code>" + |
bpatel@766 | 237 | "<a href=\"../pkg2/I.html\" title=\"interface in pkg2\">I</a>" + |
bpatel@766 | 238 | "<java.lang.String></code></dd>"}, |
bpatel@1858 | 239 | |
bpatel@1858 | 240 | //Make sure when no modifier appear in the class signature, the |
bpatel@1858 | 241 | //signature is displayed correctly without extra space at the beginning. |
bpatel@1858 | 242 | {BUG_ID + "-2" + FS + "pkg" + FS + "PrivateParent.html", |
bpatel@1858 | 243 | "<pre>class <span class=\"strong\">PrivateParent</span>"}, |
bpatel@1858 | 244 | |
bpatel@1858 | 245 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@1858 | 246 | "<pre>public class <span class=\"strong\">PublicChild</span>"}, |
duke@1 | 247 | }; |
bpatel@1858 | 248 | private static final String[][] NEGATED_TEST2 = { |
bpatel@1858 | 249 | {BUG_ID + "-2" + FS + "pkg" + FS + "PrivateParent.html", |
bpatel@1858 | 250 | "<pre> class <span class=\"strong\">PrivateParent</span>"}, |
bpatel@1858 | 251 | }; |
duke@1 | 252 | |
duke@1 | 253 | /** |
duke@1 | 254 | * The entry point of the test. |
duke@1 | 255 | * @param args the array of command line arguments. |
duke@1 | 256 | */ |
duke@1 | 257 | public static void main(String[] args) { |
duke@1 | 258 | TestPrivateClasses tester = new TestPrivateClasses(); |
duke@1 | 259 | run(tester, ARGS1, TEST1, NEGATED_TEST1); |
duke@1 | 260 | run(tester, ARGS2, TEST2, NEGATED_TEST2); |
duke@1 | 261 | tester.printSummary(); |
duke@1 | 262 | } |
duke@1 | 263 | |
duke@1 | 264 | /** |
duke@1 | 265 | * {@inheritDoc} |
duke@1 | 266 | */ |
duke@1 | 267 | public String getBugId() { |
duke@1 | 268 | return BUG_ID; |
duke@1 | 269 | } |
duke@1 | 270 | |
duke@1 | 271 | /** |
duke@1 | 272 | * {@inheritDoc} |
duke@1 | 273 | */ |
duke@1 | 274 | public String getBugName() { |
duke@1 | 275 | return getClass().getName(); |
duke@1 | 276 | } |
duke@1 | 277 | } |