0N/A/*
797N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * @test
0N/A * @bug 4780441 4874845 4978816
0N/A * @summary Make sure that when the -private flag is not used, members
0N/A * inherited from package private class are documented in the child.
0N/A *
0N/A * Make sure that when a method inherits documentation from a method
0N/A * in a non-public class/interface, the non-public class/interface
0N/A * is not mentioned anywhere (not even in the signature or tree).
0N/A *
0N/A * Make sure that when a private interface method with generic parameters
0N/A * is implemented, the comments can be inherited properly.
0N/A * @author jamieh
0N/A * @library ../lib/
0N/A * @build JavadocTester
0N/A * @build TestPrivateClasses
0N/A * @run main TestPrivateClasses
0N/A */
0N/A
0N/Apublic class TestPrivateClasses extends JavadocTester {
0N/A
0N/A //Test information.
0N/A private static final String BUG_ID = "4780441-4874845-4978816";
0N/A
0N/A //Javadoc arguments.
0N/A private static final String[] ARGS1 = new String[] {
0N/A "-d", BUG_ID + "-1", "-sourcepath", SRC_DIR, "-source", "1.5", "pkg", "pkg2"
0N/A };
0N/A private static final String[] ARGS2 = new String[] {
0N/A "-d", BUG_ID + "-2", "-sourcepath", SRC_DIR, "-private",
0N/A "-source", "1.5", "pkg", "pkg2"
0N/A };
0N/A
0N/A // Test output when -private flag is not used.
0N/A private static final String[][] TEST1 = {
0N/A // Field inheritence from non-public superclass.
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
765N/A "<a href=\"../pkg/PublicChild.html#fieldInheritedFromParent\">" +
765N/A "fieldInheritedFromParent</a>"
0N/A },
0N/A
0N/A // Method inheritence from non-public superclass.
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
765N/A "<a href=\"../pkg/PublicChild.html#methodInheritedFromParent(int)\">" +
765N/A "methodInheritedFromParent</a>"
0N/A },
0N/A
0N/A // Field inheritence from non-public superinterface.
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
765N/A "<a href=\"../pkg/PublicInterface.html#fieldInheritedFromInterface\">" +
765N/A "fieldInheritedFromInterface</a>"
0N/A },
0N/A
0N/A // Method inheritence from non-public superinterface.
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
765N/A "<a href=\"../pkg/PublicInterface.html#methodInterface(int)\">" +
765N/A "methodInterface</a>"
0N/A },
0N/A
0N/A // private class does not show up in tree
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
765N/A "<ul class=\"inheritance\">" + NL + "<li>java.lang.Object</li>" + NL +
765N/A "<li>" + NL + "<ul class=\"inheritance\">" + NL + "<li>pkg.PublicChild</li>" + NL +
765N/A "</ul>" + NL + "</li>" + NL + "</ul>"
0N/A },
0N/A
0N/A // Method is documented as though it is declared in the inheriting method.
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
765N/A "<pre>public&nbsp;void&nbsp;methodInheritedFromParent(int&nbsp;p1)"
0N/A },
0N/A
0N/A //Make sure implemented interfaces from private superclass are inherited
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
765N/A "<dl>" + NL + "<dt>All Known Implementing Classes:</dt>" + NL +
765N/A "<dd><a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">" +
765N/A "PublicChild</a></dd>" + NL + "</dl>"},
0N/A
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
765N/A "<dl>" + NL + "<dt>All Implemented Interfaces:</dt>" + NL +
765N/A "<dd><a href=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">" +
765N/A "PublicInterface</a></dd>" + NL + "</dl>"},
0N/A
0N/A //Generic interface method test.
0N/A {BUG_ID + "-1" + FS + "pkg2" + FS + "C.html",
0N/A "This comment should get copied to the implementing class"},
0N/A };
0N/A private static final String[][] NEGATED_TEST1 = {
0N/A // Should not document that a method overrides method from private class.
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
765N/A "<strong>Overrides:</strong>"},
0N/A // Should not document that a method specified by private interface.
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
765N/A "<strong>Specified by:</strong>"},
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
765N/A "<strong>Specified by:</strong>"},
0N/A // Should not mention that any documentation was copied.
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
0N/A "Description copied from"},
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
0N/A "Description copied from"},
0N/A // Don't extend private classes or interfaces
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
0N/A "PrivateParent"},
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
0N/A "PrivateInterface"},
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
0N/A "PrivateInterface"},
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
0N/A "All Superinterfaces"},
0N/A // Make inherited constant are documented correctly.
0N/A {BUG_ID + "-1" + FS + "constant-values.html",
0N/A "PrivateInterface"},
0N/A
0N/A //Do not inherit private interface method with generic parameters.
0N/A //This method has been implemented.
0N/A {BUG_ID + "-1" + FS + "pkg2" + FS + "C.html",
765N/A "<strong><a href=\"../pkg2/I.html#hello(T)\">hello</a></strong>"},
0N/A };
0N/A
0N/A // Test output when -private flag is used.
0N/A private static final String[][] TEST2 = {
0N/A // Field inheritence from non-public superclass.
0N/A {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
765N/A "Fields inherited from class&nbsp;pkg." +
765N/A "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
765N/A "PrivateParent</a>"
0N/A },
0N/A {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
765N/A "<a href=\"../pkg/PrivateParent.html#fieldInheritedFromParent\">" +
765N/A "fieldInheritedFromParent</a>"
0N/A },
0N/A // Field inheritence from non-public superinterface.
0N/A {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
765N/A "Fields inherited from interface&nbsp;pkg." +
765N/A "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
765N/A "PrivateInterface</a>"
0N/A },
0N/A {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
765N/A "<a href=\"../pkg/PrivateInterface.html#fieldInheritedFromInterface\">" +
765N/A "fieldInheritedFromInterface</a>"
0N/A },
0N/A // Method inheritence from non-public superclass.
0N/A {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
765N/A "Methods inherited from class&nbsp;pkg." +
765N/A "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
765N/A "PrivateParent</a>"
0N/A },
0N/A {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
765N/A "<a href=\"../pkg/PrivateParent.html#methodInheritedFromParent(int)\">" +
765N/A "methodInheritedFromParent</a>"
0N/A },
0N/A // Should document that a method overrides method from private class.
0N/A {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
765N/A "<dt><strong>Overrides:</strong></dt>" + NL +
765N/A "<dd><code><a href=\"../pkg/PrivateParent.html#methodOverridenFromParent(char[], int, T, V, java.util.List)\">" +
765N/A "methodOverridenFromParent</a></code>&nbsp;in class&nbsp;<code>" +
765N/A "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
765N/A "PrivateParent</a></code></dd>"},
0N/A // Should document that a method is specified by private interface.
0N/A {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
765N/A "<dt><strong>Specified by:</strong></dt>" + NL +
765N/A "<dd><code><a href=\"../pkg/PrivateInterface.html#methodInterface(int)\">" +
765N/A "methodInterface</a></code>&nbsp;in interface&nbsp;<code>" +
765N/A "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
765N/A "PrivateInterface</a></code></dd>"},
0N/A // Method inheritence from non-public superinterface.
0N/A {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
765N/A "Methods inherited from interface&nbsp;pkg." +
765N/A "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
765N/A "PrivateInterface</a>"
0N/A },
0N/A {BUG_ID + "-2" + FS + "pkg" + FS + "PrivateInterface.html",
765N/A "<a href=\"../pkg/PrivateInterface.html#methodInterface(int)\">" +
765N/A "methodInterface</a>"
0N/A },
0N/A // Should mention that any documentation was copied.
0N/A {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
0N/A "Description copied from"},
0N/A // Extend documented private classes or interfaces
0N/A {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
0N/A "extends"},
0N/A {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
0N/A "extends"},
0N/A {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
0N/A "All Superinterfaces"},
0N/A
0N/A //Make sure implemented interfaces from private superclass are inherited
0N/A {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
765N/A "<dl>" + NL + "<dt>All Known Implementing Classes:</dt>" + NL +
765N/A "<dd><a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
765N/A "PrivateParent</a>, " +
765N/A "<a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">PublicChild" +
765N/A "</a></dd>" + NL + "</dl>"},
0N/A
0N/A {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
765N/A "<dl>" + NL + "<dt>All Implemented Interfaces:</dt>" + NL +
765N/A "<dd><a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
765N/A "PrivateInterface</a>, " +
765N/A "<a href=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">" +
765N/A "PublicInterface</a></dd>" + NL + "</dl>"},
0N/A
0N/A //Since private flag is used, we can document that private interface method
0N/A //with generic parameters has been implemented.
0N/A {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html",
765N/A "<strong>Description copied from interface:&nbsp;<code>" +
765N/A "<a href=\"../pkg2/I.html#hello(T)\">I</a></code></strong>"},
0N/A
0N/A {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html",
765N/A "<dt><strong>Specified by:</strong></dt>" + NL +
765N/A "<dd><code><a href=\"../pkg2/I.html#hello(T)\">hello</a></code>" +
765N/A "&nbsp;in interface&nbsp;<code>" +
765N/A "<a href=\"../pkg2/I.html\" title=\"interface in pkg2\">I</a>" +
765N/A "&lt;java.lang.String&gt;</code></dd>"},
0N/A };
0N/A private static final String[][] NEGATED_TEST2 = NO_TEST;
0N/A
0N/A /**
0N/A * The entry point of the test.
0N/A * @param args the array of command line arguments.
0N/A */
0N/A public static void main(String[] args) {
0N/A TestPrivateClasses tester = new TestPrivateClasses();
0N/A run(tester, ARGS1, TEST1, NEGATED_TEST1);
0N/A run(tester, ARGS2, TEST2, NEGATED_TEST2);
0N/A tester.printSummary();
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public String getBugId() {
0N/A return BUG_ID;
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public String getBugName() {
0N/A return getClass().getName();
0N/A }
0N/A}