/* * Copyright 2003-2004 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ /* * @test * @bug 4780441 4874845 4978816 * @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. * @author jamieh * @library ../lib/ * @build JavadocTester * @build TestPrivateClasses * @run main TestPrivateClasses */ public class TestPrivateClasses extends JavadocTester { //Test information. private static final String BUG_ID = "4780441-4874845-4978816"; //Javadoc arguments. private static final String[] ARGS1 = new String[] { "-d", BUG_ID + "-1", "-sourcepath", SRC_DIR, "-source", "1.5", "pkg", "pkg2" }; private static final String[] ARGS2 = new String[] { "-d", BUG_ID + "-2", "-sourcepath", SRC_DIR, "-private", "-source", "1.5", "pkg", "pkg2" }; // Test output when -private flag is not used. private static final String[][] TEST1 = { // Field inheritence from non-public superclass. {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", "" + "fieldInheritedFromParent" }, // Method inheritence from non-public superclass. {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", "" + "methodInheritedFromParent" }, // Field inheritence from non-public superinterface. {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", "" + "fieldInheritedFromInterface" }, // Method inheritence from non-public superinterface. {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", "" + "methodInterface" }, // private class does not show up in tree {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", "
" + NL +
                "java.lang.Object" + NL +
                "  pkg.PublicChild" + NL +
            "
" }, // Method is documented as though it is declared in the inheriting method. {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", "public void methodInheritedFromParent(int p1)" }, //Make sure implemented interfaces from private superclass are inherited {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", "All Known Implementing Classes:
PublicChild"}, {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", "All Implemented Interfaces:
PublicInterface"}, //Generic interface method test. {BUG_ID + "-1" + FS + "pkg2" + FS + "C.html", "This comment should get copied to the implementing class"}, }; private static final String[][] NEGATED_TEST1 = { // Should not document that a method overrides method from private class. {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", "Overrides:"}, // Should not document that a method specified by private interface. {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", "Specified by:"}, {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", "Specified by:"}, // Should not mention that any documentation was copied. {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", "Description copied from"}, {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", "Description copied from"}, // Don't extend private classes or interfaces {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", "PrivateParent"}, {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", "PrivateInterface"}, {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", "PrivateInterface"}, {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", "All Superinterfaces"}, // Make inherited constant are documented correctly. {BUG_ID + "-1" + FS + "constant-values.html", "PrivateInterface"}, //Do not inherit private interface method with generic parameters. //This method has been implemented. {BUG_ID + "-1" + FS + "pkg2" + FS + "C.html", "hello"}, }; // Test output when -private flag is used. private static final String[][] TEST2 = { // Field inheritence from non-public superclass. {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", "Fields inherited from class " + "pkg.PrivateParent" }, {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", "" + "fieldInheritedFromParent" }, // Field inheritence from non-public superinterface. {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", "Fields inherited from interface " + "pkg.PrivateInterface" }, {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", "" + "fieldInheritedFromInterface" }, // Method inheritence from non-public superclass. {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", "Methods inherited from class " + "pkg.PrivateParent" }, {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", "" + "methodInheritedFromParent" }, // Should document that a method overrides method from private class. {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", "Overrides:
" + "" + "methodOverridenFromParent in class " + "" + "PrivateParent
" + NL + ""}, // Should document that a method is specified by private interface. {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", "Specified by:
" + "" + "methodInterface in interface " + "" + "PrivateInterface
" + NL + "" + NL + ""}, // Method inheritence from non-public superinterface. {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", "Methods inherited from interface " + "pkg.PrivateInterface" }, {BUG_ID + "-2" + FS + "pkg" + FS + "PrivateInterface.html", "" + "methodInterface" }, // Should mention that any documentation was copied. {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", "Description copied from"}, // Extend documented private classes or interfaces {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", "extends"}, {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", "extends"}, {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", "All Superinterfaces"}, //Make sure implemented interfaces from private superclass are inherited {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", "All Known Implementing Classes:
PrivateParent, " + "PublicChild"}, {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", "All Implemented Interfaces:
PrivateInterface, " + "" + "PublicInterface"}, //Since private flag is used, we can document that private interface method //with generic parameters has been implemented. {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html", "Description copied from interface: " + "I"}, {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html", "Specified by:
" + "hello in interface I"}, }; private static final String[][] NEGATED_TEST2 = NO_TEST; /** * The entry point of the test. * @param args the array of command line arguments. */ public static void main(String[] args) { TestPrivateClasses tester = new TestPrivateClasses(); run(tester, ARGS1, TEST1, NEGATED_TEST1); run(tester, ARGS2, TEST2, NEGATED_TEST2); tester.printSummary(); } /** * {@inheritDoc} */ public String getBugId() { return BUG_ID; } /** * {@inheritDoc} */ public String getBugName() { return getClass().getName(); } }