1 /*
2  * Copyright (c) 2013, 2016, 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 JavadocTester
32  * @run main DocTest
33  */
34 
35 /**
36  * DocTest documentation.
37  *
38  * @apiNote DocTest API note.
39  * @implSpec DocTest implementation spec.
40  * @implNote DocTest implementation note.
41  */
42 public class DocTest extends JavadocTester {
main(String... args)43     public static void main(String... args) throws Exception {
44         DocTest tester = new DocTest();
45         tester.runTests();
46     }
47 
48     @Test
test()49     void test() {
50         javadoc("-verbose",
51                 "-d", "DocTest",
52                 "-tag", "apiNote:optcm:<em>API Note</em>",
53                 "-tag", "implSpec:optcm:<em>Implementation Requirements</em>:",
54                 "-tag", "implNote:optcm:<em>Implementation Note</em>:",
55                 "-package",
56                 testSrc("DocTest.java")
57         );
58         checkExit(Exit.OK);
59 
60         // javadoc does not report an exit code for an internal exception (!)
61         // so monitor stderr for stack dumps.
62         checkOutput(Output.STDERR, false, "at com.sun");
63     }
64 
65     /**
66      * DocTest() documentation.
67      *
68      * @apiNote DocTest() API note.
69      * @implSpec DocTest() implementation spec.
70      * @implNote DocTest() implementation note.
71      */
DocTest()72     public DocTest() {
73     }
74 
75     /**
76      * DocTest.testMethod() documentation.
77      *
78      * @apiNote DocTest.testMethod() API note.
79      * @implSpec DocTest.testMethod() implementation spec.
80      * @implNote DocTest.testMethod() implementation note.
81      */
testMethod()82     public void testMethod() {
83     }
84 }
85 
86 /**
87  * DocTestWithTags documentation.
88  *
89  * @apiNote DocTestWithTags API note.
90  * <pre>
91  *    DocTestWithTags API note code sample.
92  * </pre>
93  * @implSpec DocTestWithTags implementation spec.
94  * <pre>
95  *    DocTestWithTags implementation spec code sample.
96  * </pre>
97  * @implNote DocTestWithTags implementation note.
98  * <pre>
99  *    DocTestWithTags implementation note code sample.
100  * </pre>
101  */
102 class DocTestWithTags {
103 
104     /**
105      * DocTestWithTags() documentation.
106      *
107      * @apiNote DocTestWithTags() API note.
108      * <pre>
109      *    DocTestWithTags() API note code sample.
110      * </pre>
111      * @implSpec DocTestWithTags() implementation spec.
112      * <pre>
113      *    DocTestWithTags() implementation spec code sample.
114      * </pre>
115      * @implNote DocTest() implementation note.
116      * <pre>
117      *    DocTest() implementation note code sample.
118      * </pre>
119      */
DocTestWithTags()120     public DocTestWithTags() {
121     }
122 
123     /**
124      * DocTest.testMethod() documentation.
125      *
126      * @apiNote DocTestWithTags.testMethod() API note.
127      * <pre>
128      *    DocTestWithTags.testMethod() API note code sample.
129      * </pre>
130      * @implSpec DocTestWithTags.testMethod() implementation spec.
131      * <pre>
132      *    DocTestWithTags.testMethod() API implementation spec code sample.
133      * </pre>
134      * @implNote DocTest.testMethod() implementation note.
135      * <pre>
136      *    DocTest.testMethod() API implementation code sample.
137      * </pre>
138      */
testMethod()139     public void testMethod() {
140     }
141 }
142 
143 class MinimallyExtendsDocTest extends DocTest {
144 }
145 
146 /**
147  * SimpleExtendsDocTest documentation.
148  */
149 class SimpleExtendsDocTest extends DocTest {
150 
151     /**
152      * SimpleExtendsDocTest() documentation.
153      */
SimpleExtendsDocTest()154     public SimpleExtendsDocTest() {
155 
156     }
157 
158     /**
159      * SimpleExtendsDocTest.testMethod() documenation.
160      */
161     @java.lang.Override
testMethod()162     public void testMethod() {
163     }
164 }
165 
166 /**
167  * {@inheritDoc}
168  */
169 class SimpleInheritDocDocTest extends DocTest {
170 
171     /**
172      * {@inheritDoc}
173      */
SimpleInheritDocDocTest()174     public SimpleInheritDocDocTest() {
175     }
176 
177     /**
178      * {@inheritDoc}
179      */
180     @java.lang.Override
testMethod()181     public void testMethod() {
182     }
183 }
184 
185 /**
186  * {@inheritDoc}
187  *
188  * @apiNote {@inheritDoc}
189  * @implSpec {@inheritDoc}
190  * @implNote {@inheritDoc}
191  */
192 class FullInheritDocDocTest extends DocTest {
193 
194     /**
195      * {@inheritDoc}
196      *
197      * @apiNote {@inheritDoc}
198      * @implSpec {@inheritDoc}
199      * @implNote {@inheritDoc}
200      */
FullInheritDocDocTest()201     public FullInheritDocDocTest() {
202 
203     }
204 
205     /**
206      * {@inheritDoc}
207      *
208      * @apiNote {@inheritDoc}
209      * @implSpec {@inheritDoc}
210      * @implNote {@inheritDoc}
211      */
212     @java.lang.Override
testMethod()213     public void testMethod() {
214     }
215 }
216 
217 /**
218  * {@inheritDoc} and FullInheritDocPlusDocTest documentation.
219  *
220  * @implSpec {@inheritDoc} and FullInheritDocPlusDocTest API note.
221  * @implNote {@inheritDoc} and FullInheritDocPlusDocTest implementation specification.
222  * @apiNote {@inheritDoc} and FullInheritDocPlusDocTest implementation note.
223  */
224 class FullInheritDocPlusDocTest extends DocTest {
225 
226     /**
227      * {@inheritDoc} and FullInheritDocPlusDocTest() documentation.
228      *
229      * @implSpec {@inheritDoc} and FullInheritDocPlusDocTest() API note.
230      * @implNote {@inheritDoc} and FullInheritDocPlusDocTest() implementation specification.
231      * @apiNote {@inheritDoc} and FullInheritDocPlusDocTest() implementation note.
232      */
FullInheritDocPlusDocTest()233     public FullInheritDocPlusDocTest() {
234 
235     }
236 
237     /**
238      * {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() documentation.
239      *
240      * @implSpec {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() API note.
241      * @implNote {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() implementation specification.
242      * @apiNote {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() implementation note.
243      */
244     @java.lang.Override
testMethod()245     public void testMethod() {
246     }
247 }
248 
249