|
| 1 | +/* |
| 2 | + * Copyright (c) 2022, 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 8284299 |
| 27 | + * @library /tools/lib ../../lib |
| 28 | + * @modules jdk.javadoc/jdk.javadoc.internal.tool |
| 29 | + * @build toolbox.ToolBox javadoc.tester.* |
| 30 | + * @run main TestInheritDocWithinInappropriateTag |
| 31 | + */ |
| 32 | + |
| 33 | +import java.nio.file.Path; |
| 34 | + |
| 35 | +import javadoc.tester.JavadocTester; |
| 36 | +import toolbox.ToolBox; |
| 37 | + |
| 38 | +public class TestInheritDocWithinInappropriateTag extends JavadocTester { |
| 39 | + |
| 40 | + public static void main(String... args) throws Exception { |
| 41 | + new TestInheritDocWithinInappropriateTag() |
| 42 | + .runTests(m -> new Object[]{Path.of(m.getName())}); |
| 43 | + } |
| 44 | + |
| 45 | + private final ToolBox tb = new ToolBox(); |
| 46 | + |
| 47 | + @Test |
| 48 | + public void test(Path base) throws Exception { |
| 49 | + Path src = base.resolve("src"); |
| 50 | + tb.writeJavaFiles(src, |
| 51 | + """ |
| 52 | + public class A { |
| 53 | + /** |
| 54 | + * A.x(). |
| 55 | + */ |
| 56 | + public void x() { } |
| 57 | + } |
| 58 | + """, |
| 59 | + """ |
| 60 | + public class B extends A { |
| 61 | + /** |
| 62 | + * {@summary {@inheritDoc}} |
| 63 | + * |
| 64 | + * {@link Object#hashCode() {@inheritDoc}} |
| 65 | + * {@linkplain Object#hashCode() {@inheritDoc}} |
| 66 | + * |
| 67 | + * {@index term {@inheritDoc}} |
| 68 | + */ |
| 69 | + @Override |
| 70 | + public void x() { } |
| 71 | + } |
| 72 | + """); |
| 73 | + javadoc("-Xdoclint:none", |
| 74 | + "-d", base.resolve("out").toString(), |
| 75 | + src.resolve("A.java").toString(), |
| 76 | + src.resolve("B.java").toString()); |
| 77 | + checkExit(Exit.OK); |
| 78 | + new OutputChecker(Output.OUT).setExpectOrdered(false).check( |
| 79 | + """ |
| 80 | + warning: @inheritDoc cannot be used within this tag |
| 81 | + * {@summary {@inheritDoc}} |
| 82 | + ^ |
| 83 | + """, |
| 84 | + """ |
| 85 | + warning: @inheritDoc cannot be used within this tag |
| 86 | + * {@link Object#hashCode() {@inheritDoc}} |
| 87 | + ^ |
| 88 | + """, |
| 89 | + """ |
| 90 | + warning: @inheritDoc cannot be used within this tag |
| 91 | + * {@linkplain Object#hashCode() {@inheritDoc}} |
| 92 | + ^ |
| 93 | + """, |
| 94 | + """ |
| 95 | + warning: @inheritDoc cannot be used within this tag |
| 96 | + * {@index term {@inheritDoc}} |
| 97 | + ^ |
| 98 | + """); |
| 99 | + } |
| 100 | +} |
0 commit comments