8176901: Internal error running javadoc over jdk internal classes
authorksrini
Tue, 04 Apr 2017 11:27:06 -0700
changeset 44563 01e04897d1e8
parent 44461 8e5061e5b34b
child 44564 4e1df2513486
8176901: Internal error running javadoc over jdk internal classes Reviewed-by: jjg
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/JavaScriptScanner.java
langtools/test/jdk/javadoc/doclet/testBadHtml/TestBadHtml.java
langtools/test/jdk/javadoc/doclet/testBadHtml/pkg1/A.java
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/JavaScriptScanner.java	Mon Apr 03 12:40:41 2017 +0100
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/JavaScriptScanner.java	Tue Apr 04 11:27:06 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. 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
@@ -95,7 +95,7 @@
             case "datasrc":  case "for":  case "href":  case "longdesc":  case "profile":
             case "src":  case "usemap":
                 List<? extends DocTree> value = tree.getValue();
-                if (!value.isEmpty() && value.get(0).getKind() == Kind.TEXT) {
+                if (value != null && !value.isEmpty() && value.get(0).getKind() == Kind.TEXT) {
                     String v = value.get(0).toString().trim().toLowerCase(Locale.ENGLISH);
                     if (v.startsWith("javascript:")) {
                         f.accept(getCurrentPath());
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testBadHtml/TestBadHtml.java	Tue Apr 04 11:27:06 2017 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8176901
+ * @summary The doclet should cope with bad HTML form
+ * @library ../lib
+ * @modules jdk.javadoc/jdk.javadoc.internal.tool
+ * @build JavadocTester
+ * @run main TestBadHtml
+ */
+
+public class TestBadHtml extends JavadocTester {
+
+    public static void main(String... args) throws Exception {
+        TestBadHtml tester = new TestBadHtml();
+        tester.runTests();
+    }
+
+    @Test
+    void testNegative() {
+        javadoc("-d", "out1",
+                "-sourcepath", testSrc,
+                "pkg1");
+
+        checkExit(Exit.ERROR);
+
+        checkOutput(Output.STDERR, false, "NullPointerException");
+        checkOutput(Output.OUT, false, "NullPointerException");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testBadHtml/pkg1/A.java	Tue Apr 04 11:27:06 2017 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg1;
+
+/**
+ * The first sentence.
+ * <parameters the word action is crucial here object>
+ * <parameters the word cite is crucial here object>
+ * <parameters the word classid is crucial here object>
+ * <parameters the word codebase is crucial here object>
+ * <parameters the word data is crucial here object>
+ * <parameters the word datasrc is crucial here object>
+ * <parameters the word for is crucial here object>
+ * <parameters the word href is crucial here object>
+ * <parameters the word longdesc is crucial here object>
+ * <parameters the word profile is crucial here object>
+ * <parameters the word src is crucial here object>
+ * <parameters the word usemap is crucial here object>
+ */
+
+public class A {}