test/langtools/tools/javadoc/T6968833.java
author bobv
Tue, 07 Nov 2017 10:30:53 -0500
changeset 47801 c7b50c23ea71
parent 47216 71c04702a3d5
permissions -rw-r--r--
8190283: Default heap sizing options select a MaxHeapSize larger than available physical memory in some cases Reviewed-by: tschatzl, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8633
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
     1
/*
45742
36bf0f2436ad 8177511: Remove the old standard doclet
ksrini
parents: 30730
diff changeset
     2
 * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
8633
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
     4
 *
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
     8
 *
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    13
 * accompanied this code).
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    14
 *
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    18
 *
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    21
 * questions.
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    22
 */
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    23
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    24
/*
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    25
 * @test
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    26
 * @bug 6968833
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    27
 * @summary javadoc reports error but still returns 0
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 8633
diff changeset
    28
 * @modules jdk.javadoc
45742
36bf0f2436ad 8177511: Remove the old standard doclet
ksrini
parents: 30730
diff changeset
    29
 * @library lib
36bf0f2436ad 8177511: Remove the old standard doclet
ksrini
parents: 30730
diff changeset
    30
 * @build ToyDoclet
36bf0f2436ad 8177511: Remove the old standard doclet
ksrini
parents: 30730
diff changeset
    31
 * @run main T6968833
8633
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    32
 */
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    33
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    34
import java.io.*;
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    35
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    36
public class T6968833 {
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    37
    public static void main(String... args) throws IOException {
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    38
        new T6968833().run();
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    39
    }
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    40
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    41
    void run() throws IOException {
45742
36bf0f2436ad 8177511: Remove the old standard doclet
ksrini
parents: 30730
diff changeset
    42
        String testClasses = System.getProperty("test.classes");
36bf0f2436ad 8177511: Remove the old standard doclet
ksrini
parents: 30730
diff changeset
    43
8633
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    44
        File srcDir = new File("src");
45742
36bf0f2436ad 8177511: Remove the old standard doclet
ksrini
parents: 30730
diff changeset
    45
        // following file cause a doclet error, as there is nothing to document
8633
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    46
        File f = writeFile(srcDir, "Foo.java", "class Foo { }");
45742
36bf0f2436ad 8177511: Remove the old standard doclet
ksrini
parents: 30730
diff changeset
    47
        String[] args = { "-docletpath", testClasses,
36bf0f2436ad 8177511: Remove the old standard doclet
ksrini
parents: 30730
diff changeset
    48
                "-doclet", "ToyDoclet",
36bf0f2436ad 8177511: Remove the old standard doclet
ksrini
parents: 30730
diff changeset
    49
                f.getPath() };
8633
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    50
        int rc = com.sun.tools.javadoc.Main.execute(args);
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    51
        if (rc == 0)
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    52
            throw new Error("Unexpected exit from javadoc: " + rc);
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    53
    }
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    54
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    55
    File writeFile(File dir, String path, String s) throws IOException {
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    56
        File f = new File(dir, path);
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    57
        f.getParentFile().mkdirs();
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    58
        try (Writer out = new FileWriter(f)) {
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    59
            out.write(s);
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    60
        }
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    61
        return f;
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    62
    }
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    63
}
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff changeset
    64