|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
23 | 23 |
|
24 | 24 | /*
|
25 | 25 | * @test
|
26 |
| - * @bug 4632553 4973607 8026567 |
| 26 | + * @bug 4632553 4973607 8026567 8242564 |
27 | 27 | * @summary No need to include type name (class, interface, etc.) before
|
28 | 28 | * every single type in class tree.
|
29 | 29 | * Make sure class tree includes heirarchy for enums and annotation
|
30 | 30 | * types.
|
31 |
| - * @library ../../lib |
| 31 | + * Make sure class tree handles undefined types in the class |
| 32 | + * hierarchy. |
| 33 | + * @library /tools/lib ../../lib |
32 | 34 | * @modules jdk.javadoc/jdk.javadoc.internal.tool
|
33 |
| - * @build javadoc.tester.* |
| 35 | + * @build toolbox.ToolBox javadoc.tester.* |
34 | 36 | * @run main TestClassTree
|
35 | 37 | */
|
36 | 38 |
|
| 39 | +import java.io.IOException; |
| 40 | +import java.nio.file.Path; |
| 41 | + |
37 | 42 | import javadoc.tester.JavadocTester;
|
| 43 | +import toolbox.ToolBox; |
38 | 44 |
|
39 | 45 | public class TestClassTree extends JavadocTester {
|
40 | 46 |
|
| 47 | + private final ToolBox tb = new ToolBox(); |
| 48 | + |
41 | 49 | public static void main(String... args) throws Exception {
|
42 | 50 | var tester = new TestClassTree();
|
43 | 51 | tester.runTests();
|
44 | 52 | }
|
45 | 53 |
|
| 54 | + /** |
| 55 | + * Given badpkg package containing class ChildClass with UndefinedClass |
| 56 | + * base class, implementing UndefinedInterface and a defined |
| 57 | + * interface |
| 58 | + * When the javadoc is generated with '--ignore-source-errors option' |
| 59 | + * Then javadoc exits successfully |
| 60 | + * And generates html for the ChildClass with UndefinedClass base class |
| 61 | + * And UndefinedInterface is not present in html |
| 62 | + */ |
| 63 | + @Test |
| 64 | + public void testBadPkg(Path base) throws IOException { |
| 65 | + Path src = base.resolve("src"); |
| 66 | + tb.writeJavaFiles(src, |
| 67 | + """ |
| 68 | + package badpkg; |
| 69 | + public class ChildClass extends UndefinedClass |
| 70 | + implements UndefinedInterface, Iterable { |
| 71 | +
|
| 72 | + } |
| 73 | + """ |
| 74 | + ); |
| 75 | + |
| 76 | + javadoc("--ignore-source-errors", |
| 77 | + "-d", base.resolve("badout").toString(), |
| 78 | + "--no-platform-links", |
| 79 | + "-sourcepath", src.toString(), |
| 80 | + "badpkg"); |
| 81 | + |
| 82 | + |
| 83 | + checkExit(Exit.OK); |
| 84 | + checkOutput("badpkg/package-tree.html", true, |
| 85 | + """ |
| 86 | + <li class="circle">badpkg.<a href="ChildClass.html" class="type-name-link" title="\ |
| 87 | + class in badpkg">ChildClass</a> (implements java.lang.Iterable<T>)</li> |
| 88 | + """); |
| 89 | + checkOutput("badpkg/ChildClass.html", true, |
| 90 | + """ |
| 91 | + <div class="type-signature"><span class="modifiers">public class </span>\ |
| 92 | + <span class="element-name type-name-label">ChildClass</span> |
| 93 | + <span class="extends-implements">extends UndefinedClass |
| 94 | + implements java.lang.Iterable</span></div> |
| 95 | + """); |
| 96 | + checkOutput("badpkg/ChildClass.html", false, "UndefinedInterface"); |
| 97 | + } |
| 98 | + |
46 | 99 | @Test
|
47 | 100 | public void test() {
|
48 | 101 | javadoc("-d", "out",
|
|
0 commit comments