Sat, 01 Dec 2007 00:00:00 +0000
Initial load
duke@1 | 1 | /* |
duke@1 | 2 | * Copyright 2003-2004 Sun Microsystems, Inc. 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 | * |
duke@1 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@1 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@1 | 21 | * have any questions. |
duke@1 | 22 | */ |
duke@1 | 23 | |
duke@1 | 24 | /* |
duke@1 | 25 | * @test |
duke@1 | 26 | * @bug 4780441 4874845 4978816 |
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. |
duke@1 | 36 | * @author jamieh |
duke@1 | 37 | * @library ../lib/ |
duke@1 | 38 | * @build JavadocTester |
duke@1 | 39 | * @build TestPrivateClasses |
duke@1 | 40 | * @run main TestPrivateClasses |
duke@1 | 41 | */ |
duke@1 | 42 | |
duke@1 | 43 | public class TestPrivateClasses extends JavadocTester { |
duke@1 | 44 | |
duke@1 | 45 | //Test information. |
duke@1 | 46 | private static final String BUG_ID = "4780441-4874845-4978816"; |
duke@1 | 47 | |
duke@1 | 48 | //Javadoc arguments. |
duke@1 | 49 | private static final String[] ARGS1 = new String[] { |
duke@1 | 50 | "-d", BUG_ID + "-1", "-sourcepath", SRC_DIR, "-source", "1.5", "pkg", "pkg2" |
duke@1 | 51 | }; |
duke@1 | 52 | private static final String[] ARGS2 = new String[] { |
duke@1 | 53 | "-d", BUG_ID + "-2", "-sourcepath", SRC_DIR, "-private", |
duke@1 | 54 | "-source", "1.5", "pkg", "pkg2" |
duke@1 | 55 | }; |
duke@1 | 56 | |
duke@1 | 57 | // Test output when -private flag is not used. |
duke@1 | 58 | private static final String[][] TEST1 = { |
duke@1 | 59 | // Field inheritence from non-public superclass. |
duke@1 | 60 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 61 | "<A HREF=\"../pkg/PublicChild.html#fieldInheritedFromParent\">" + |
duke@1 | 62 | "fieldInheritedFromParent</A>" |
duke@1 | 63 | }, |
duke@1 | 64 | |
duke@1 | 65 | // Method inheritence from non-public superclass. |
duke@1 | 66 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 67 | "<A HREF=\"../pkg/PublicChild.html#methodInheritedFromParent(int)\">" + |
duke@1 | 68 | "methodInheritedFromParent</A>" |
duke@1 | 69 | }, |
duke@1 | 70 | |
duke@1 | 71 | // Field inheritence from non-public superinterface. |
duke@1 | 72 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 73 | "<A HREF=\"../pkg/PublicInterface.html#fieldInheritedFromInterface\">" + |
duke@1 | 74 | "fieldInheritedFromInterface</A>" |
duke@1 | 75 | }, |
duke@1 | 76 | |
duke@1 | 77 | // Method inheritence from non-public superinterface. |
duke@1 | 78 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 79 | "<A HREF=\"../pkg/PublicInterface.html#methodInterface(int)\">" + |
duke@1 | 80 | "methodInterface</A>" |
duke@1 | 81 | }, |
duke@1 | 82 | |
duke@1 | 83 | // private class does not show up in tree |
duke@1 | 84 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 85 | "<PRE>" + NL + |
duke@1 | 86 | "java.lang.Object" + NL + |
duke@1 | 87 | " <IMG SRC=\"../resources/inherit.gif\" " + |
duke@1 | 88 | "ALT=\"extended by \"><B>pkg.PublicChild</B>" + NL + |
duke@1 | 89 | "</PRE>" |
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", |
duke@1 | 94 | "public void <B>methodInheritedFromParent</B>(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", |
duke@1 | 99 | "<B>All Known Implementing Classes:</B> <DD><A HREF=\"../pkg/PublicChild.html\" " + |
duke@1 | 100 | "title=\"class in pkg\">PublicChild</A>"}, |
duke@1 | 101 | |
duke@1 | 102 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 103 | "<B>All Implemented Interfaces:</B> <DD><A HREF=\"../pkg/PublicInterface.html\" " + |
duke@1 | 104 | "title=\"interface in pkg\">PublicInterface</A>"}, |
duke@1 | 105 | |
duke@1 | 106 | //Generic interface method test. |
duke@1 | 107 | {BUG_ID + "-1" + FS + "pkg2" + FS + "C.html", |
duke@1 | 108 | "This comment should get copied to the implementing class"}, |
duke@1 | 109 | }; |
duke@1 | 110 | private static final String[][] NEGATED_TEST1 = { |
duke@1 | 111 | // Should not document that a method overrides method from private class. |
duke@1 | 112 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 113 | "<B>Overrides:</B>"}, |
duke@1 | 114 | // Should not document that a method specified by private interface. |
duke@1 | 115 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 116 | "<B>Specified by:</B>"}, |
duke@1 | 117 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 118 | "<B>Specified by:</B>"}, |
duke@1 | 119 | // Should not mention that any documentation was copied. |
duke@1 | 120 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 121 | "Description copied from"}, |
duke@1 | 122 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 123 | "Description copied from"}, |
duke@1 | 124 | // Don't extend private classes or interfaces |
duke@1 | 125 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 126 | "PrivateParent"}, |
duke@1 | 127 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 128 | "PrivateInterface"}, |
duke@1 | 129 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 130 | "PrivateInterface"}, |
duke@1 | 131 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 132 | "All Superinterfaces"}, |
duke@1 | 133 | // Make inherited constant are documented correctly. |
duke@1 | 134 | {BUG_ID + "-1" + FS + "constant-values.html", |
duke@1 | 135 | "PrivateInterface"}, |
duke@1 | 136 | |
duke@1 | 137 | //Do not inherit private interface method with generic parameters. |
duke@1 | 138 | //This method has been implemented. |
duke@1 | 139 | {BUG_ID + "-1" + FS + "pkg2" + FS + "C.html", |
duke@1 | 140 | "<B><A HREF=\"../pkg2/I.html#hello(T)\">hello</A></B>"}, |
duke@1 | 141 | }; |
duke@1 | 142 | |
duke@1 | 143 | // Test output when -private flag is used. |
duke@1 | 144 | private static final String[][] TEST2 = { |
duke@1 | 145 | // Field inheritence from non-public superclass. |
duke@1 | 146 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 147 | "Fields inherited from class " + |
duke@1 | 148 | "pkg.<A HREF=\"../pkg/PrivateParent.html\" " + |
duke@1 | 149 | "title=\"class in pkg\">PrivateParent</A>" |
duke@1 | 150 | }, |
duke@1 | 151 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 152 | "<A HREF=\"../pkg/PrivateParent.html#fieldInheritedFromParent\">" + |
duke@1 | 153 | "fieldInheritedFromParent</A>" |
duke@1 | 154 | }, |
duke@1 | 155 | // Field inheritence from non-public superinterface. |
duke@1 | 156 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 157 | "Fields inherited from interface " + |
duke@1 | 158 | "pkg.<A HREF=\"../pkg/PrivateInterface.html\" " + |
duke@1 | 159 | "title=\"interface in pkg\">PrivateInterface</A>" |
duke@1 | 160 | }, |
duke@1 | 161 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 162 | "<A HREF=\"../pkg/PrivateInterface.html#fieldInheritedFromInterface\">" + |
duke@1 | 163 | "fieldInheritedFromInterface</A>" |
duke@1 | 164 | }, |
duke@1 | 165 | // Method inheritence from non-public superclass. |
duke@1 | 166 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 167 | "Methods inherited from class " + |
duke@1 | 168 | "pkg.<A HREF=\"../pkg/PrivateParent.html\" " + |
duke@1 | 169 | "title=\"class in pkg\">PrivateParent</A>" |
duke@1 | 170 | }, |
duke@1 | 171 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 172 | "<A HREF=\"../pkg/PrivateParent.html#methodInheritedFromParent(int)\">" + |
duke@1 | 173 | "methodInheritedFromParent</A>" |
duke@1 | 174 | }, |
duke@1 | 175 | // Should document that a method overrides method from private class. |
duke@1 | 176 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 177 | "<B>Overrides:</B><DD><CODE>" + |
duke@1 | 178 | "<A HREF=\"../pkg/PrivateParent.html#methodOverridenFromParent(char[], int, T, V, java.util.List)\">" + |
duke@1 | 179 | "methodOverridenFromParent</A></CODE> in class <CODE>" + |
duke@1 | 180 | "<A HREF=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" + |
duke@1 | 181 | "PrivateParent</A></CODE></DL>"}, |
duke@1 | 182 | // Should document that a method is specified by private interface. |
duke@1 | 183 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 184 | "<B>Specified by:</B><DD><CODE>" + |
duke@1 | 185 | "<A HREF=\"../pkg/PrivateInterface.html#methodInterface(int)\">" + |
duke@1 | 186 | "methodInterface</A></CODE> in interface <CODE>" + |
duke@1 | 187 | "<A HREF=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" + |
duke@1 | 188 | "PrivateInterface</A></CODE></DL>" + NL + "</DD>"}, |
duke@1 | 189 | // Method inheritence from non-public superinterface. |
duke@1 | 190 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 191 | "Methods inherited from interface " + |
duke@1 | 192 | "pkg.<A HREF=\"../pkg/PrivateInterface.html\" " + |
duke@1 | 193 | "title=\"interface in pkg\">PrivateInterface</A>" |
duke@1 | 194 | }, |
duke@1 | 195 | {BUG_ID + "-2" + FS + "pkg" + FS + "PrivateInterface.html", |
duke@1 | 196 | "<A HREF=\"../pkg/PrivateInterface.html#methodInterface(int)\">" + |
duke@1 | 197 | "methodInterface</A>" |
duke@1 | 198 | }, |
duke@1 | 199 | // Should mention that any documentation was copied. |
duke@1 | 200 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 201 | "Description copied from"}, |
duke@1 | 202 | // Extend documented private classes or interfaces |
duke@1 | 203 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 204 | "extends"}, |
duke@1 | 205 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 206 | "extends"}, |
duke@1 | 207 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 208 | "All Superinterfaces"}, |
duke@1 | 209 | |
duke@1 | 210 | //Make sure implemented interfaces from private superclass are inherited |
duke@1 | 211 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 212 | "<B>All Known Implementing Classes:</B> <DD><A HREF=\"../pkg/PrivateParent.html\" " + |
duke@1 | 213 | "title=\"class in pkg\">PrivateParent</A>, " + |
duke@1 | 214 | "<A HREF=\"../pkg/PublicChild.html\" title=\"class in pkg\">PublicChild</A>"}, |
duke@1 | 215 | |
duke@1 | 216 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 217 | "<B>All Implemented Interfaces:</B> <DD><A HREF=\"../pkg/PrivateInterface.html\" " + |
duke@1 | 218 | "title=\"interface in pkg\">PrivateInterface</A>, " + |
duke@1 | 219 | "<A HREF=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">" + |
duke@1 | 220 | "PublicInterface</A>"}, |
duke@1 | 221 | |
duke@1 | 222 | //Since private flag is used, we can document that private interface method |
duke@1 | 223 | //with generic parameters has been implemented. |
duke@1 | 224 | {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html", |
duke@1 | 225 | "<B>Description copied from interface: " + |
duke@1 | 226 | "<CODE><A HREF=\"../pkg2/I.html#hello(T)\">I</A></CODE></B>"}, |
duke@1 | 227 | |
duke@1 | 228 | {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html", |
duke@1 | 229 | "<B>Specified by:</B><DD><CODE><A HREF=\"../pkg2/I.html#hello(T)\">" + |
duke@1 | 230 | "hello</A></CODE> in interface <CODE><A HREF=\"../pkg2/I.html\" " + |
duke@1 | 231 | "title=\"interface in pkg2\">I</A>"}, |
duke@1 | 232 | }; |
duke@1 | 233 | private static final String[][] NEGATED_TEST2 = NO_TEST; |
duke@1 | 234 | |
duke@1 | 235 | /** |
duke@1 | 236 | * The entry point of the test. |
duke@1 | 237 | * @param args the array of command line arguments. |
duke@1 | 238 | */ |
duke@1 | 239 | public static void main(String[] args) { |
duke@1 | 240 | TestPrivateClasses tester = new TestPrivateClasses(); |
duke@1 | 241 | run(tester, ARGS1, TEST1, NEGATED_TEST1); |
duke@1 | 242 | run(tester, ARGS2, TEST2, NEGATED_TEST2); |
duke@1 | 243 | tester.printSummary(); |
duke@1 | 244 | } |
duke@1 | 245 | |
duke@1 | 246 | /** |
duke@1 | 247 | * {@inheritDoc} |
duke@1 | 248 | */ |
duke@1 | 249 | public String getBugId() { |
duke@1 | 250 | return BUG_ID; |
duke@1 | 251 | } |
duke@1 | 252 | |
duke@1 | 253 | /** |
duke@1 | 254 | * {@inheritDoc} |
duke@1 | 255 | */ |
duke@1 | 256 | public String getBugName() { |
duke@1 | 257 | return getClass().getName(); |
duke@1 | 258 | } |
duke@1 | 259 | } |