/* * 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. "" + "fieldInheritedFromParent", // Method inheritance from non-public superclass. "" + "methodInheritedFromParent", // private class does not show up in tree "
public void methodInheritedFromParent(int p1)", "
"
+ "PublicInterface
"
+ ""
+ "methodInterface(int p1)
\n"
+ ""
+ ""
+ "methodInterface2(int p1)
\n"
+ ""
+ "PublicChild
"
+ ""
+ "methodInterface(int p1)
\n"
+ ""
+ ""
+ "methodInterface2(int p1)
\n"
+ ""
+ "methodOverridenFromParent
in class "
+ ""
+ "PrivateParent
"
+ "methodInterface
in interface "
+ ""
+ "PrivateInterface
"
+ "PrivateInterface
, "
+ ""
+ "PublicInterface
public class PublicChild");
checkOutput("pkg/PublicInterface.html", true,
// Field inheritence from non-public superinterface.
"Fields inherited from interface pkg."
+ ""
+ "PrivateInterface",
""
+ "fieldInheritedFromInterface",
// Method inheritance from non-public superinterface.
"Methods inherited from interface pkg."
+ ""
+ "PrivateInterface",
// Extend documented private classes or interfaces
"extends",
"All Superinterfaces",
//Make sure implemented interfaces from private superclass are inherited
"
"
+ "PrivateParent
, "
+ "PublicChild"
+ "
"
+ "I
",
"hello
"
+ " in interface "
+ "I"
+ "<java.lang.String>
class PrivateParent");
checkOutput("pkg/PrivateParent.html", false,
" class PrivateParent");
}
@Test
void testPrivate_html4() {
javadoc("-d", "out-private-html4",
"-html4",
"-sourcepath", testSrc,
"-private",
"pkg", "pkg2");
checkExit(Exit.OK);
checkOutput("pkg/PublicChild.html", true,
""
+ "methodInheritedFromParent",
// Should document that a method overrides method from private class.
"
"
+ "methodOverridenFromParent
in class "
+ ""
+ "PrivateParent
"
+ "methodInterface
in interface "
+ ""
+ "PrivateInterface
"
+ "I
",
"hello
"
+ " in interface "
+ "I"
+ "<java.lang.String>