changeset 56984:fa802f216fb2 amber-demo-II

Automatic merge with records-and-sealed
author mcimadamore
date Sat, 10 Aug 2019 00:49:40 +0000
parents a59d56df3851 79c030f0364a
children c0de553f0b3f
files
diffstat 2 files changed, 69 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Fri Aug 09 23:35:44 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Sat Aug 10 00:49:40 2019 +0000
@@ -269,9 +269,10 @@
             boolean isFirst = true;
             for (TypeMirror type : permits) {
                 TypeElement tDoc = utils.asTypeElement(type);
-                if (!(utils.isPublic(tDoc) || utils.isLinkable(tDoc))) {
-                    continue;
-                }
+                // Document all permitted subtypes, not just public linkable types,
+                // because it may be of interest to the reader that not all of the
+                // subtypes may be accessible: for example, in a pattern statement
+                // switching on the type of an object.
                 if (isFirst) {
                     pre.add(DocletConstants.NL);
                     pre.add("permits ");
--- a/test/langtools/jdk/javadoc/doclet/testSealedTypes/TestSealedTypes.java	Fri Aug 09 23:35:44 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testSealedTypes/TestSealedTypes.java	Sat Aug 10 00:49:40 2019 +0000
@@ -187,10 +187,10 @@
 
         checkOutput("p/A.html", true,
                 "<pre>public sealed class <span class=\"typeNameLabel\">A</span>\n"
-                        + "extends java.lang.Object\n"
-                        + "permits <a href=\"B.html\" title=\"class in p\">B</a>, "
-                        + "<a href=\"C.html\" title=\"class in p\">C</a>, "
-                        + "<a href=\"D.html\" title=\"class in p\">D</a></pre>");
+                + "extends java.lang.Object\n"
+                + "permits <a href=\"B.html\" title=\"class in p\">B</a>, "
+                + "<a href=\"C.html\" title=\"class in p\">C</a>, "
+                + "<a href=\"D.html\" title=\"class in p\">D</a></pre>");
     }
 
     @Test
@@ -209,9 +209,55 @@
 
         checkOutput("p/A.html", true,
                 "<pre>public sealed class <span class=\"typeNameLabel\">A</span>\n"
-                        + "extends java.lang.Object\n"
-                        + "permits <a href=\"B.html\" title=\"class in p\">B</a>, "
-                        + "<a href=\"C.html\" title=\"class in p\">C</a></pre>");
+                + "extends java.lang.Object\n"
+                + "permits <a href=\"B.html\" title=\"class in p\">B</a>, "
+                + "<a href=\"C.html\" title=\"class in p\">C</a>, p.D</pre>");
+    }
+
+    @Test
+    public void testPartialMultiplePermitsWithSubtypes1(Path base) throws IOException {
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src,
+                "package p; public sealed class A permits B,C,D { }",
+                "package p; public class B extends A { }",
+                "package p; public class C extends A { }",
+                "package p;        sealed class D extends A permits D1, D2 { }",
+                "package p; public class D1 extends D { }",
+                "package p; public class D2 extends D { }");
+
+        javadoc("-d", base.resolve("out").toString(),
+                "--source-path", src.toString(),
+                "p");
+        checkExit(Exit.OK);
+
+        checkOutput("p/A.html", true,
+                "<pre>public sealed class <span class=\"typeNameLabel\">A</span>\n"
+                + "extends java.lang.Object\n"
+                + "permits <a href=\"B.html\" title=\"class in p\">B</a>, "
+                + "<a href=\"C.html\" title=\"class in p\">C</a>, p.D</pre>");
+    }
+
+    @Test
+    public void testPartialMultiplePermitsWithSubtypes2(Path base) throws IOException {
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src,
+                "package p; public sealed class A permits B,C,D { }",
+                "package p; public class B extends A { }",
+                "package p; public class C extends A { }",
+                "package p;        non-sealed class D extends A { }",
+                "package p; public class D1 extends D { }",
+                "package p; public class D2 extends D { }");
+
+        javadoc("-d", base.resolve("out").toString(),
+                "--source-path", src.toString(),
+                "p");
+        checkExit(Exit.OK);
+
+        checkOutput("p/A.html", true,
+                "<pre>public sealed class <span class=\"typeNameLabel\">A</span>\n"
+                + "extends java.lang.Object\n"
+                + "permits <a href=\"B.html\" title=\"class in p\">B</a>, "
+                + "<a href=\"C.html\" title=\"class in p\">C</a>, p.D</pre>");
     }
 
     @Test
@@ -231,10 +277,10 @@
 
         checkOutput("p/A.html", true,
                 "<pre>public sealed class <span class=\"typeNameLabel\">A</span>\n"
-                        + "extends java.lang.Object\n"
-                        + "permits <a href=\"B.html\" title=\"class in p\">B</a>, "
-                        + "<a href=\"C.html\" title=\"class in p\">C</a>, "
-                        + "<a href=\"D.html\" title=\"class in p\">D</a></pre>");
+                + "extends java.lang.Object\n"
+                + "permits <a href=\"B.html\" title=\"class in p\">B</a>, "
+                + "<a href=\"C.html\" title=\"class in p\">C</a>, "
+                + "<a href=\"D.html\" title=\"class in p\">D</a></pre>");
     }
 
     @Test
@@ -242,10 +288,10 @@
         Path src = base.resolve("src");
         tb.writeJavaFiles(src,
                 "package p; public sealed class A {\n"
-                        + "  public static class B extends A { }\n"
-                        + "  public static class C extends A { }\n"
-                        + "  public static class D extends A { }\n"
-                        + "}");
+                + "  public static class B extends A { }\n"
+                + "  public static class C extends A { }\n"
+                + "  public static class D extends A { }\n"
+                + "}");
 
         javadoc("-d", base.resolve("out").toString(),
                 "--source-path", src.toString(),
@@ -254,9 +300,9 @@
 
         checkOutput("p/A.html", true,
                 "<pre>public sealed class <span class=\"typeNameLabel\">A</span>\n"
-                        + "extends java.lang.Object\n"
-                        + "permits <a href=\"A.B.html\" title=\"class in p\">A.B</a>, "
-                        + "<a href=\"A.C.html\" title=\"class in p\">A.C</a>, "
-                        + "<a href=\"A.D.html\" title=\"class in p\">A.D</a></pre>");
+                + "extends java.lang.Object\n"
+                + "permits <a href=\"A.B.html\" title=\"class in p\">A.B</a>, "
+                + "<a href=\"A.C.html\" title=\"class in p\">A.C</a>, "
+                + "<a href=\"A.D.html\" title=\"class in p\">A.D</a></pre>");
     }
 }