From f4883897ce5ff7d88a1c382bdfd67f855e328836 Mon Sep 17 00:00:00 2001 From: Peter von der Ahe Date: Tue, 8 Sep 2009 13:53:10 -0700 Subject: [PATCH] 5093723: REGRESSION: ClassCastException in SingleIndexWriter Reviewed-by: jjg --- .../formats/html/HtmlDocletWriter.java | 12 +++- .../html/resources/standard.properties | 1 + .../sun/javadoc/5093723/DocumentedClass.java | 34 +++++++++++ .../com/sun/javadoc/5093723/T5093723.java | 57 +++++++++++++++++++ .../javadoc/5093723/UndocumentedClass.java | 29 ++++++++++ 5 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 langtools/test/com/sun/javadoc/5093723/DocumentedClass.java create mode 100644 langtools/test/com/sun/javadoc/5093723/T5093723.java create mode 100644 langtools/test/com/sun/javadoc/5093723/UndocumentedClass.java diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java index 453b8e8e74a..37415017f99 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java @@ -1435,7 +1435,17 @@ public class HtmlDocletWriter extends HtmlDocWriter { // 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; diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties index f4d86e3d5d8..598cc88d74b 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties @@ -69,6 +69,7 @@ doclet.URL_error=Error fetching URL: {0} 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 diff --git a/langtools/test/com/sun/javadoc/5093723/DocumentedClass.java b/langtools/test/com/sun/javadoc/5093723/DocumentedClass.java new file mode 100644 index 00000000000..abdc9f7f5de --- /dev/null +++ b/langtools/test/com/sun/javadoc/5093723/DocumentedClass.java @@ -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() {} +} diff --git a/langtools/test/com/sun/javadoc/5093723/T5093723.java b/langtools/test/com/sun/javadoc/5093723/T5093723.java new file mode 100644 index 00000000000..d442daa6676 --- /dev/null +++ b/langtools/test/com/sun/javadoc/5093723/T5093723.java @@ -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(); + } +} diff --git a/langtools/test/com/sun/javadoc/5093723/UndocumentedClass.java b/langtools/test/com/sun/javadoc/5093723/UndocumentedClass.java new file mode 100644 index 00000000000..ccbaa0805ed --- /dev/null +++ b/langtools/test/com/sun/javadoc/5093723/UndocumentedClass.java @@ -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() {} +}