5093723: REGRESSION: ClassCastException in SingleIndexWriter
Reviewed-by: jjg
Contributed-by: ahe@google.com
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Wed Jul 05 17:00:34 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Tue Sep 08 13:53:10 2009 -0700
@@ -1435,7 +1435,17 @@
// documented, this must be an inherited link. Redirect it.
// The current class either overrides the referenced member or
// inherits it automatically.
- containing = ((ClassWriterImpl) this).getClassDoc();
+ if (this instanceof ClassWriterImpl) {
+ containing = ((ClassWriterImpl) this).getClassDoc();
+ } else if (!containing.isPublic()){
+ configuration.getDocletSpecificMsg().warning(
+ see.position(), "doclet.see.class_or_package_not_accessible",
+ tagName, containing.qualifiedName());
+ } else {
+ configuration.getDocletSpecificMsg().warning(
+ see.position(), "doclet.see.class_or_package_not_found",
+ tagName, seetext);
+ }
}
if (configuration.currentcd != containing) {
refMemName = containing.name() + "." + refMemName;
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties Wed Jul 05 17:00:34 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties Tue Sep 08 13:53:10 2009 -0700
@@ -69,6 +69,7 @@
doclet.No_Package_Comment_File=For Package {0} Package.Comment file not found
doclet.No_Source_For_Class=Source information for class {0} not available.
doclet.see.class_or_package_not_found=Tag {0}: reference not found: {1}
+doclet.see.class_or_package_not_accessible=Tag {0}: reference not accessible: {1}
doclet.see.malformed_tag=Tag {0}: Malformed: {1}
doclet.Inherited_API_Summary=Inherited API Summary
doclet.Deprecated_API=Deprecated API
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/5093723/DocumentedClass.java Tue Sep 08 13:53:10 2009 -0700
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2009 Google, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/** A documented class. */
+public class DocumentedClass extends UndocumentedClass {
+ /** {@link #method} */
+ public void m1() {}
+ /** {@link #publicMethod} */
+ public void m2() {}
+ /** {@link #protectedMethod} */
+ public void m3() {}
+ /** {@link #privateMethod} */
+ public void m4() {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/5093723/T5093723.java Tue Sep 08 13:53:10 2009 -0700
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2009 Google, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 5093723
+ * @summary REGRESSION: ClassCastException in SingleIndexWriter
+ * @library ../lib/
+ * @build JavadocTester
+ * @build T5093723
+ * @run main T5093723
+ */
+
+public class T5093723 extends JavadocTester {
+
+ private static final String BUG_ID = "5093723";
+
+ private static final String[] ARGS = new String[] {
+ "-d", BUG_ID + ".out", "-source", "5",
+ SRC_DIR + "/DocumentedClass.java",
+ SRC_DIR + "/UndocumentedClass.java"
+ };
+
+ public static void main(String... args) {
+ T5093723 tester = new T5093723();
+ if (tester.runJavadoc(ARGS) != 0)
+ throw new AssertionError("non-zero return code from javadoc");
+ }
+
+ public String getBugId() {
+ return BUG_ID;
+ }
+
+ public String getBugName() {
+ return getClass().getName();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/5093723/UndocumentedClass.java Tue Sep 08 13:53:10 2009 -0700
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2009 Google, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+class UndocumentedClass {
+ void method() {}
+ public void publicMethod() {}
+ protected void protectedMethod() {}
+ private void privateMethod() {}
+}