1 /*
2  * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.
8  *
9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  */
23 
24 /*
25  * @test
26  * @bug 8008768
27  * @summary Using {@inheritDoc} in simple tag defined via -tag fails
28  * @author Mike Duigou
29  * @library ../../lib
30  * @modules jdk.javadoc/jdk.javadoc.internal.tool
31  * @build javadoc.tester.*
32  * @run main DocTest
33  */
34 
35 import javadoc.tester.JavadocTester;
36 
37 /**
38  * DocTest documentation.
39  *
40  * @apiNote DocTest API note.
41  * @implSpec DocTest implementation spec.
42  * @implNote DocTest implementation note.
43  */
44 public class DocTest extends JavadocTester {
main(String... args)45     public static void main(String... args) throws Exception {
46         DocTest tester = new DocTest();
47         tester.runTests();
48     }
49 
50     @Test
test()51     public void test() {
52         javadoc("-verbose",
53                 "-d", "DocTest",
54                 "-sourcepath", System.getProperty("test.src.path"),
55                 "-tag", "apiNote:optcm:<em>API Note</em>",
56                 "-tag", "implSpec:optcm:<em>Implementation Requirements</em>:",
57                 "-tag", "implNote:optcm:<em>Implementation Note</em>:",
58                 "-package",
59                 testSrc("DocTest.java")
60         );
61         checkExit(Exit.OK);
62 
63         // javadoc does not report an exit code for an internal exception (!)
64         // so monitor stderr for stack dumps.
65         checkOutput(Output.STDERR, false, "at com.sun");
66     }
67 
68     /**
69      * DocTest() documentation.
70      *
71      * @apiNote DocTest() API note.
72      * @implSpec DocTest() implementation spec.
73      * @implNote DocTest() implementation note.
74      */
DocTest()75     public DocTest() {
76     }
77 
78     /**
79      * DocTest.testMethod() documentation.
80      *
81      * @apiNote DocTest.testMethod() API note.
82      * @implSpec DocTest.testMethod() implementation spec.
83      * @implNote DocTest.testMethod() implementation note.
84      */
testMethod()85     public void testMethod() {
86     }
87 }
88 
89 /**
90  * DocTestWithTags documentation.
91  *
92  * @apiNote DocTestWithTags API note.
93  * <pre>
94  *    DocTestWithTags API note code sample.
95  * </pre>
96  * @implSpec DocTestWithTags implementation spec.
97  * <pre>
98  *    DocTestWithTags implementation spec code sample.
99  * </pre>
100  * @implNote DocTestWithTags implementation note.
101  * <pre>
102  *    DocTestWithTags implementation note code sample.
103  * </pre>
104  */
105 class DocTestWithTags {
106 
107     /**
108      * DocTestWithTags() documentation.
109      *
110      * @apiNote DocTestWithTags() API note.
111      * <pre>
112      *    DocTestWithTags() API note code sample.
113      * </pre>
114      * @implSpec DocTestWithTags() implementation spec.
115      * <pre>
116      *    DocTestWithTags() implementation spec code sample.
117      * </pre>
118      * @implNote DocTest() implementation note.
119      * <pre>
120      *    DocTest() implementation note code sample.
121      * </pre>
122      */
DocTestWithTags()123     public DocTestWithTags() {
124     }
125 
126     /**
127      * DocTest.testMethod() documentation.
128      *
129      * @apiNote DocTestWithTags.testMethod() API note.
130      * <pre>
131      *    DocTestWithTags.testMethod() API note code sample.
132      * </pre>
133      * @implSpec DocTestWithTags.testMethod() implementation spec.
134      * <pre>
135      *    DocTestWithTags.testMethod() API implementation spec code sample.
136      * </pre>
137      * @implNote DocTest.testMethod() implementation note.
138      * <pre>
139      *    DocTest.testMethod() API implementation code sample.
140      * </pre>
141      */
testMethod()142     public void testMethod() {
143     }
144 }
145 
146 class MinimallyExtendsDocTest extends DocTest {
147 }
148 
149 /**
150  * SimpleExtendsDocTest documentation.
151  */
152 class SimpleExtendsDocTest extends DocTest {
153 
154     /**
155      * SimpleExtendsDocTest() documentation.
156      */
SimpleExtendsDocTest()157     public SimpleExtendsDocTest() {
158 
159     }
160 
161     /**
162      * SimpleExtendsDocTest.testMethod() documenation.
163      */
164     @java.lang.Override
testMethod()165     public void testMethod() {
166     }
167 }
168 
169 /**
170  * {@inheritDoc}
171  */
172 class SimpleInheritDocDocTest extends DocTest {
173 
174     /**
175      * {@inheritDoc}
176      */
SimpleInheritDocDocTest()177     public SimpleInheritDocDocTest() {
178     }
179 
180     /**
181      * {@inheritDoc}
182      */
183     @java.lang.Override
testMethod()184     public void testMethod() {
185     }
186 }
187 
188 /**
189  * {@inheritDoc}
190  *
191  * @apiNote {@inheritDoc}
192  * @implSpec {@inheritDoc}
193  * @implNote {@inheritDoc}
194  */
195 class FullInheritDocDocTest extends DocTest {
196 
197     /**
198      * {@inheritDoc}
199      *
200      * @apiNote {@inheritDoc}
201      * @implSpec {@inheritDoc}
202      * @implNote {@inheritDoc}
203      */
FullInheritDocDocTest()204     public FullInheritDocDocTest() {
205 
206     }
207 
208     /**
209      * {@inheritDoc}
210      *
211      * @apiNote {@inheritDoc}
212      * @implSpec {@inheritDoc}
213      * @implNote {@inheritDoc}
214      */
215     @java.lang.Override
testMethod()216     public void testMethod() {
217     }
218 }
219 
220 /**
221  * {@inheritDoc} and FullInheritDocPlusDocTest documentation.
222  *
223  * @implSpec {@inheritDoc} and FullInheritDocPlusDocTest API note.
224  * @implNote {@inheritDoc} and FullInheritDocPlusDocTest implementation specification.
225  * @apiNote {@inheritDoc} and FullInheritDocPlusDocTest implementation note.
226  */
227 class FullInheritDocPlusDocTest extends DocTest {
228 
229     /**
230      * {@inheritDoc} and FullInheritDocPlusDocTest() documentation.
231      *
232      * @implSpec {@inheritDoc} and FullInheritDocPlusDocTest() API note.
233      * @implNote {@inheritDoc} and FullInheritDocPlusDocTest() implementation specification.
234      * @apiNote {@inheritDoc} and FullInheritDocPlusDocTest() implementation note.
235      */
FullInheritDocPlusDocTest()236     public FullInheritDocPlusDocTest() {
237 
238     }
239 
240     /**
241      * {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() documentation.
242      *
243      * @implSpec {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() API note.
244      * @implNote {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() implementation specification.
245      * @apiNote {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() implementation note.
246      */
247     @java.lang.Override
testMethod()248     public void testMethod() {
249     }
250 }
251 
252