|
| 1 | +/* |
| 2 | + * Copyright (c) 2002, 2020, 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 8253700 |
| 27 | + * @summary spurious "extends Throwable" at end of method declaration |
| 28 | + * throws section. Make sure that the link is below a Throws heading. |
| 29 | + * @library /tools/lib ../../lib |
| 30 | + * @modules jdk.javadoc/jdk.javadoc.internal.tool |
| 31 | + * @build javadoc.tester.* toolbox.ToolBox |
| 32 | + * @run main TestThrows |
| 33 | + */ |
| 34 | + |
| 35 | + import java.io.IOException; |
| 36 | + import java.nio.file.Path; |
| 37 | + |
| 38 | + import toolbox.ToolBox; |
| 39 | + |
| 40 | + import javadoc.tester.JavadocTester; |
| 41 | + |
| 42 | + public class TestThrows extends JavadocTester { |
| 43 | + |
| 44 | + public static void main(String... args) throws Exception { |
| 45 | + TestThrows tester = new TestThrows(); |
| 46 | + tester.runTests(m -> new Object[] { Path.of(m.getName()) }); |
| 47 | + } |
| 48 | + |
| 49 | + private final ToolBox tb = new ToolBox(); |
| 50 | + |
| 51 | + @Test |
| 52 | + public void testThrowsWithBound(Path base) throws IOException { |
| 53 | + Path src = base.resolve("src"); |
| 54 | + tb.writeJavaFiles(src, |
| 55 | + """ |
| 56 | + /** |
| 57 | + * This is interface C. |
| 58 | + */ |
| 59 | + public interface C { |
| 60 | + /** |
| 61 | + * Method m. |
| 62 | + * @param <T> the throwable |
| 63 | + * @throws T if a specific error occurs |
| 64 | + * @throws Exception if an exception occurs |
| 65 | + */ |
| 66 | + <T extends Throwable> void m() throws T, Exception; |
| 67 | + } |
| 68 | + """); |
| 69 | + |
| 70 | + javadoc("-d", base.resolve("out").toString(), |
| 71 | + src.resolve("C.java").toString()); |
| 72 | + checkExit(Exit.OK); |
| 73 | + |
| 74 | + checkOutput("C.html", true, |
| 75 | + """ |
| 76 | + <div class="member-signature"><span class="type-parameters"><T extends java\ |
| 77 | + .lang.Throwable></span> <span class="return-type">void</span> <sp\ |
| 78 | + an class="member-name">m</span>() |
| 79 | + throws <span class="exceptions">T, |
| 80 | + java.lang.Exception</span></div> |
| 81 | + """, |
| 82 | + """ |
| 83 | + <dl class="notes"> |
| 84 | + <dt>Type Parameters:</dt> |
| 85 | + <dd><code>T</code> - the throwable</dd> |
| 86 | + <dt>Throws:</dt> |
| 87 | + <dd><code>T</code> - if a specific error occurs</dd> |
| 88 | + <dd><code>java.lang.Exception</code> - if an exception occurs</dd> |
| 89 | + </dl> |
| 90 | + """); |
| 91 | + } |
| 92 | +} |
0 commit comments