8175219: javadoc should exit when it encounters compilation errors.
authorksrini
Mon, 13 Mar 2017 16:46:17 -0700
changeset 44287 829205b133d4
parent 44197 380e1f22e460
child 44288 c33a416cfcf8
8175219: javadoc should exit when it encounters compilation errors. Reviewed-by: jjg, bpatel
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocEnter.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolEnvironment.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java
langtools/test/jdk/javadoc/doclet/testClassTree/pkg/Coin.java
langtools/test/jdk/javadoc/doclet/testMissingType/TestMissingType.java
langtools/test/jdk/javadoc/doclet/testModules/moduleB/testpkgmdlB/AnnotationType.java
langtools/test/jdk/javadoc/doclet/testModules/moduleB/testpkgmdlB/AnnotationTypeUndocumented.java
langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/TestRepeatedAnnotations.java
langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/C.java
langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/D.java
langtools/test/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java
langtools/test/jdk/javadoc/doclet/testTypeAnnotations/typeannos/Receivers.java
langtools/test/jdk/javadoc/tool/IgnoreSourceErrors.java
langtools/test/jdk/javadoc/tool/ReleaseOption.java
langtools/test/jdk/javadoc/tool/T6551367.java
langtools/test/jdk/javadoc/tool/badSuper/BadSuper.java
langtools/test/jdk/javadoc/tool/outputRedirect/p/OutputRedirect.java
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocEnter.java	Mon Mar 13 11:27:30 2017 -0700
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocEnter.java	Mon Mar 13 16:46:17 2017 -0700
@@ -74,12 +74,14 @@
 
     @Override
     public void main(List<JCCompilationUnit> trees) {
-        // count all Enter errors as warnings.
+        // cache the error count if we need to convert Enter errors as warnings.
         int nerrors = messager.nerrors;
         super.main(trees);
         compiler.enterDone();
-        messager.nwarnings += (messager.nerrors - nerrors);
-        messager.nerrors = nerrors;
+        if (toolEnv.ignoreSourceErrors) {
+            messager.nwarnings += (messager.nerrors - nerrors);
+            messager.nerrors = nerrors;
+        }
     }
 
     @Override
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java	Mon Mar 13 11:27:30 2017 -0700
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java	Mon Mar 13 16:46:17 2017 -0700
@@ -205,6 +205,11 @@
             // Enter symbols for all files
             toolEnv.notice("main.Building_tree");
             javadocEnter.main(classTrees.toList().appendList(packageTrees));
+
+            if (messager.hasErrors()) {
+                return null;
+            }
+
             etable.setClassDeclList(listClasses(classTrees.toList()));
 
             etable.analyze();
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolEnvironment.java	Mon Mar 13 11:27:30 2017 -0700
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolEnvironment.java	Mon Mar 13 16:46:17 2017 -0700
@@ -103,11 +103,12 @@
 
     final Symbol externalizableSym;
 
-    /**
-     * True if we do not want to print any notifications at all.
-     */
+    /** If true, prevent printing of any notifications. */
     boolean quiet = false;
 
+    /** If true, ignore all errors encountered during Enter. */
+    boolean ignoreSourceErrors = false;
+
     Check chk;
     com.sun.tools.javac.code.Types types;
     JavaFileManager fileManager;
@@ -163,6 +164,7 @@
 
     public void initialize(Map<ToolOption, Object> toolOpts) {
         this.quiet = (boolean)toolOpts.getOrDefault(ToolOption.QUIET, false);
+        this.ignoreSourceErrors = (boolean)toolOpts.getOrDefault(ToolOption.IGNORE_SOURCE_ERRORS, false);
     }
 
     /**
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java	Mon Mar 13 11:27:30 2017 -0700
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java	Mon Mar 13 16:46:17 2017 -0700
@@ -329,6 +329,13 @@
         }
     },
 
+    IGNORE_SOURCE_ERRORS("--ignore-source-errors", HIDDEN) {
+        @Override
+        public void process(Helper helper) {
+            helper.jdtoolOpts.put(IGNORE_SOURCE_ERRORS, true);
+        }
+    },
+
     // ----- help options -----
 
     HELP("--help -help", STANDARD) {
--- a/langtools/test/jdk/javadoc/doclet/testClassTree/pkg/Coin.java	Mon Mar 13 11:27:30 2017 -0700
+++ b/langtools/test/jdk/javadoc/doclet/testClassTree/pkg/Coin.java	Mon Mar 13 16:46:17 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -29,9 +29,7 @@
  * @author Jamie Ho
  */
 public enum Coin {
-
-  Penny, Nickel, Dime;
+    Penny, Nickel, Dime;
 
-public Coin(int i) {}
-
+    Coin(int i) {}
 }
--- a/langtools/test/jdk/javadoc/doclet/testMissingType/TestMissingType.java	Mon Mar 13 11:27:30 2017 -0700
+++ b/langtools/test/jdk/javadoc/doclet/testMissingType/TestMissingType.java	Mon Mar 13 16:46:17 2017 -0700
@@ -44,7 +44,8 @@
                 "-use",
                 "-sourcepath", testSrc,
                 "p");
-        checkExit(Exit.OK);
-        checkFiles(true, "p/class-use/MissingType.html");
+        checkExit(Exit.ERROR);
+        checkOutput(Output.STDERR, false,
+                "java.lang.UnsupportedOperationException: should not happen");
     }
 }
--- a/langtools/test/jdk/javadoc/doclet/testModules/moduleB/testpkgmdlB/AnnotationType.java	Mon Mar 13 11:27:30 2017 -0700
+++ b/langtools/test/jdk/javadoc/doclet/testModules/moduleB/testpkgmdlB/AnnotationType.java	Mon Mar 13 16:46:17 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
@@ -28,7 +28,7 @@
 /**
  * This is a test annotation type.
  */
-@Documented public @interface AnnotationType {
+@Documented @Target(ElementType.MODULE)   public @interface AnnotationType {
 
     /**
      * The copyright holder.
--- a/langtools/test/jdk/javadoc/doclet/testModules/moduleB/testpkgmdlB/AnnotationTypeUndocumented.java	Mon Mar 13 11:27:30 2017 -0700
+++ b/langtools/test/jdk/javadoc/doclet/testModules/moduleB/testpkgmdlB/AnnotationTypeUndocumented.java	Mon Mar 13 16:46:17 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
@@ -29,7 +29,7 @@
  * This is a test annotation type this is not documented because it
  * is missing the @Documented tag.
  */
-public @interface AnnotationTypeUndocumented {
+@Target(ElementType.MODULE) public @interface AnnotationTypeUndocumented {
 
     /**
      * The copyright holder.
--- a/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/TestRepeatedAnnotations.java	Mon Mar 13 11:27:30 2017 -0700
+++ b/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/TestRepeatedAnnotations.java	Mon Mar 13 16:46:17 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -61,22 +61,7 @@
                 + "<a href=\"../pkg/RegContaineeNotDoc.html\" "
                 + "title=\"annotation in pkg\">@RegContaineeNotDoc</a>,"
                 + "<a href=\"../pkg/RegContaineeNotDoc.html\" "
-                + "title=\"annotation in pkg\">@RegContaineeNotDoc</a>})",
-                "<a href=\"../pkg/ContaineeSynthDoc.html\" "
-                + "title=\"annotation in pkg\">@ContaineeSynthDoc</a> "
-                + "<a href=\"../pkg/ContaineeSynthDoc.html\" "
-                + "title=\"annotation in pkg\">@ContaineeSynthDoc</a> "
-                + "<a href=\"../pkg/ContaineeSynthDoc.html\" "
-                + "title=\"annotation in pkg\">@ContaineeSynthDoc</a>",
-                "<a href=\"../pkg/ContainerSynthDoc.html\" "
-                + "title=\"annotation in pkg\">@ContainerSynthDoc</a>("
-                + ""
-                + "<a href=\"../pkg/ContaineeSynthDoc.html\" "
-                + "title=\"annotation in pkg\">@ContaineeSynthDoc</a>)",
-                "<a href=\"../pkg/ContaineeSynthDoc.html\" "
-                + "title=\"annotation in pkg\">@ContaineeSynthDoc</a> "
-                + "<a href=\"../pkg/ContaineeSynthDoc.html\" "
-                + "title=\"annotation in pkg\">@ContaineeSynthDoc</a>");
+                + "title=\"annotation in pkg\">@RegContaineeNotDoc</a>})");
 
         checkOutput("pkg/D.html", true,
                 "<a href=\"../pkg/RegDoc.html\" title=\"annotation in pkg\">@RegDoc</a>"
@@ -88,7 +73,8 @@
                 "<a href=\"../pkg/NonSynthDocContainer.html\" "
                 + "title=\"annotation in pkg\">@NonSynthDocContainer</a>"
                 + "("
-                + "<a href=\"../pkg/RegArryDoc.html\" title=\"annotation in pkg\">@RegArryDoc</a>)");
+                + "<a href=\"../pkg/RegArryDoc.html\" title=\"annotation in pkg\">@RegArryDoc</a>"
+                + "(<a href=\"../pkg/RegArryDoc.html#y--\">y</a>=1))");
 
         checkOutput("pkg1/C.html", true,
                 "<a href=\"../pkg1/RegContainerValDoc.html\" "
--- a/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/C.java	Mon Mar 13 11:27:30 2017 -0700
+++ b/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/C.java	Mon Mar 13 16:46:17 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -28,7 +28,6 @@
 @RegContainerDoc({@RegContaineeNotDoc,@RegContaineeNotDoc})
 @ContainerRegNotDoc({@RegContaineeDoc,@RegContaineeDoc})
 @RegContainerNotDoc({@RegContaineeNotDoc,@RegContaineeNotDoc})
-@ContaineeSynthDoc @ContaineeSynthDoc @ContaineeSynthDoc
 public class C {
 
     @ContainerSynthDoc({@ContaineeSynthDoc})
--- a/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/D.java	Mon Mar 13 11:27:30 2017 -0700
+++ b/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/D.java	Mon Mar 13 16:46:17 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -32,6 +32,6 @@
     @RegArryDoc(y={1,2})
     public void test2() {}
 
-    @NonSynthDocContainer({@RegArryDoc})
+    @NonSynthDocContainer({@RegArryDoc(y={1})})
     public void test3() {}
 }
--- a/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java	Mon Mar 13 11:27:30 2017 -0700
+++ b/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java	Mon Mar 13 16:46:17 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -343,10 +343,10 @@
                 + "                                    throws java.lang.Exception</pre>");
 
         checkOutput("typeannos/WithFinal.html", true,
-                "<pre>java.lang.String&nbsp;nonVoid(<a href=\"../typeannos/RcvrB."
-                + "html\" title=\"annotation in typeannos\">@RcvrB</a>("
-                + "\"m\")&nbsp;WithFinal"
-                + "&nbsp;this)</pre>");
+                "<pre>java.lang.String&nbsp;nonVoid(<a href=\"../typeannos/RcvrB.html\" "
+                + "title=\"annotation in typeannos\">@RcvrB</a>(\"m\") "
+                + "<a href=\"../typeannos/WithFinal.html\" title=\"class in typeannos\">"
+                + "WithFinal</a>&nbsp;afield)</pre>");
 
         checkOutput("typeannos/WithBody.html", true,
                 "<pre>void&nbsp;field(<a href=\"../typeannos/RcvrA.html\" title=\""
--- a/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/typeannos/Receivers.java	Mon Mar 13 11:27:30 2017 -0700
+++ b/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/typeannos/Receivers.java	Mon Mar 13 16:46:17 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -53,11 +53,12 @@
 }
 
 class WithFinal {
-    void plain(final @RcvrB("m") WithFinal this) { }
-    <T> void generic(final @RcvrB("m") WithFinal this) { }
-    void withException(final @RcvrB("m") WithFinal this) throws Exception { }
-    String nonVoid(final @RcvrB("m") WithFinal this) { return null; }
-    <T extends Runnable> void accept(final @RcvrB("m") WithFinal this, T r) throws Exception { }
+    WithFinal afield;
+    void plain(final @RcvrB("m") WithFinal afield) { }
+    <T> void generic(final @RcvrB("m") WithFinal afield) { }
+    void withException(final @RcvrB("m") WithFinal afield) throws Exception { }
+    String nonVoid(final @RcvrB("m") WithFinal afield) { return null; }
+    <T extends Runnable> void accept(final @RcvrB("m") WithFinal afield, T r) throws Exception { }
 }
 
 class WithBody {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/tool/IgnoreSourceErrors.java	Mon Mar 13 16:46:17 2017 -0700
@@ -0,0 +1,96 @@
+/*
+ * 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 8175219
+ * @summary test --ignore-errors works correctly
+ * @modules
+ *      jdk.javadoc/jdk.javadoc.internal.api
+ *      jdk.javadoc/jdk.javadoc.internal.tool
+ *      jdk.compiler/com.sun.tools.javac.api
+ *      jdk.compiler/com.sun.tools.javac.main
+ * @library /tools/lib
+ * @build toolbox.ToolBox toolbox.TestRunner
+ * @run main IgnoreSourceErrors
+ */
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
+import java.util.Arrays;
+
+import toolbox.*;
+import toolbox.Task.*;
+
+/**
+ * Dummy javadoc comment.
+ */
+public class IgnoreSourceErrors  extends TestRunner {
+
+    final ToolBox tb;
+    final Path testSrc;
+
+    public IgnoreSourceErrors() throws IOException {
+        super(System.err);
+        tb = new ToolBox();
+        testSrc = Paths.get("Foo.java");
+        emitSample(testSrc);
+    }
+
+    public static void main(String... args) throws Exception {
+        new IgnoreSourceErrors().runTests();
+    }
+
+    @Test
+    public void runIgnoreErrorsOffByDefault() throws Exception {
+        JavadocTask task = new JavadocTask(tb, Task.Mode.CMDLINE);
+        task.options(testSrc.toString());
+        Task.Result result = task.run(Expect.FAIL);
+        String out = result.getOutput(OutputKind.DIRECT);
+        if (!out.contains("modifier static not allowed here")) {
+            throw new Exception("expected string not found \'modifier static not allowed here\'");
+        }
+    }
+
+    @Test
+    public void runIgnoreErrorsOn() throws Exception {
+        JavadocTask task = new JavadocTask(tb, Task.Mode.CMDLINE);
+        task.options("--ignore-source-errors", testSrc.toString());
+        Task.Result result = task.run(Expect.SUCCESS);
+        String out = result.getOutput(OutputKind.DIRECT);
+        if (!out.contains("modifier static not allowed here")) {
+            throw new Exception("expected string not found \'modifier static not allowed here\'");
+        }
+    }
+
+    void emitSample(Path file) throws IOException {
+        String[] contents = {
+            "/** A java file with errors */",
+            "public static class Foo {}"
+        };
+        Files.write(file, Arrays.asList(contents), StandardOpenOption.CREATE);
+    }
+}
--- a/langtools/test/jdk/javadoc/tool/ReleaseOption.java	Mon Mar 13 11:27:30 2017 -0700
+++ b/langtools/test/jdk/javadoc/tool/ReleaseOption.java	Mon Mar 13 16:46:17 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -47,7 +47,7 @@
     }
 
     void run() {
-        doRunTest(OK, out -> out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "7");
+        doRunTest(ERROR, out -> out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "7");
         doRunTest(OK, out -> !out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "8");
         doRunTest(CMDERR, out -> true, "--release", "7", "-source", "7");
         doRunTest(CMDERR, out -> true, "--release", "7", "-bootclasspath", "any");
--- a/langtools/test/jdk/javadoc/tool/T6551367.java	Mon Mar 13 11:27:30 2017 -0700
+++ b/langtools/test/jdk/javadoc/tool/T6551367.java	Mon Mar 13 16:46:17 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -37,8 +37,6 @@
 
 import jdk.javadoc.doclet.DocletEnvironment;
 
-import static jdk.javadoc.internal.tool.Main.execute;
-
 public class T6551367 {
     public T6551367() {}
     public boolean run(DocletEnvironment root) {
@@ -59,7 +57,7 @@
                 destDir.getAbsolutePath()
             };
 
-            int rc = execute(array);
+            int rc = jdk.javadoc.internal.tool.Main.execute(array);
             if (rc != 0)
                 throw new Error("unexpected exit from javadoc: " + rc);
         }
--- a/langtools/test/jdk/javadoc/tool/badSuper/BadSuper.java	Mon Mar 13 11:27:30 2017 -0700
+++ b/langtools/test/jdk/javadoc/tool/badSuper/BadSuper.java	Mon Mar 13 16:46:17 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -34,7 +34,7 @@
         String srcpath = System.getProperty("test.src", ".");
 
         if (jdk.javadoc.internal.tool.Main.execute(
-                new String[] {"-d", "doc", "-sourcepath", srcpath, "p"}) != 0)
-            throw new Error("Javadoc encountered warnings or errors.");
+                new String[] {"-d", "doc", "-sourcepath", srcpath, "p"}) == 0)
+            throw new Error("Javadoc passed unexpectedly");
     }
 }
--- a/langtools/test/jdk/javadoc/tool/outputRedirect/p/OutputRedirect.java	Mon Mar 13 11:27:30 2017 -0700
+++ b/langtools/test/jdk/javadoc/tool/outputRedirect/p/OutputRedirect.java	Mon Mar 13 16:46:17 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -24,7 +24,6 @@
 package p;
 
 import java.io.*;
-import jdk.javadoc.internal.tool.Main;
 
 public class OutputRedirect {
     private static final PrintStream originalOutput = System.err;
@@ -47,9 +46,9 @@
         PrintWriter sink = new PrintWriter(new ByteArrayOutputStream());
 
         // execute javadoc
-        int result = Main.execute(new String[] {"p"}, sink);
+        int result = jdk.javadoc.internal.tool.Main.execute(new String[] {"p"}, sink);
 
-        // test whether javadoc did any output to System.out
+        // tests whether javadoc wrote to System.out
         if (redirectedOutput.toByteArray().length > 0) {
             originalOutput.println("Test failed; here's what javadoc wrote on its standard output:");
             originalOutput.println(redirectedOutput.toString());