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