DoclintOtherModules.java revision 3822:d8766c39123a
1132451Sroberto/*
2132451Sroberto * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
3182007Sroberto * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4132451Sroberto *
5182007Sroberto * This code is free software; you can redistribute it and/or modify it
6182007Sroberto * under the terms of the GNU General Public License version 2 only, as
7182007Sroberto * published by the Free Software Foundation.
8285169Scy *
9200576Sroberto * This code is distributed in the hope that it will be useful, but WITHOUT
10182007Sroberto * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11200576Sroberto * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12200576Sroberto * version 2 for more details (a copy is included in the LICENSE file that
13182007Sroberto * accompanied this code).
14182007Sroberto *
15132451Sroberto * You should have received a copy of the GNU General Public License version
16182007Sroberto * 2 along with this work; if not, write to the Free Software Foundation,
17182007Sroberto * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18280849Scy *
19310419Sdelphij * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20285169Scy * or visit www.oracle.com if you need additional information or have any
21182007Sroberto * questions.
22182007Sroberto */
23200576Sroberto
24200576Sroberto/**
25200576Sroberto * @test
26280849Scy * @summary Verify that DocLint does not cause unnecessary (and potentially dangerous) implicit compilation
27182007Sroberto * @library /tools/lib
28285169Scy * @modules
29285169Scy *      jdk.compiler/com.sun.tools.javac.api
30285169Scy *      jdk.compiler/com.sun.tools.javac.main
31285169Scy * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase
32285169Scy * @run main DoclintOtherModules
33285169Scy */
34285169Scy
35285169Scyimport java.nio.file.Files;
36285169Scyimport java.nio.file.Path;
37285169Scy
38285169Scyimport toolbox.JavacTask;
39285169Scyimport toolbox.Task;
40285169Scyimport toolbox.ToolBox;
41285169Scy
42285169Scypublic class DoclintOtherModules extends ModuleTestBase {
43285169Scy
44285169Scy    public static void main(String... args) throws Exception {
45182007Sroberto        DoclintOtherModules t = new DoclintOtherModules();
46280849Scy        t.runTests();
47280849Scy    }
48285169Scy
49182007Sroberto    @Test
50200576Sroberto    public void testSimple(Path base) throws Exception {
51285169Scy        Path src = base.resolve("src");
52280849Scy        Path m1 = src.resolve("m1x");
53285169Scy        Path m2 = src.resolve("m2x");
54285169Scy        tb.writeJavaFiles(m1,
55285169Scy                          "module m1x {}",
56280849Scy                          "package m1x; /** @see m2x.B */ @Deprecated public class A {}");
57285169Scy        tb.writeJavaFiles(m2,
58285169Scy                          "module m2x { requires m1x; exports m2x; }",
59280849Scy                          "package m2x; public class B extends Foo {} @Deprecated class Foo {}");
60280849Scy        Path classes = base.resolve("classes");
61280849Scy        Files.createDirectories(classes);
62280849Scy
63280849Scy        String log = new JavacTask(tb)
64280849Scy                .options("-XDrawDiagnostics", "--module-source-path", src.toString(), "-Xlint:deprecation", "-Xdoclint:-reference", "-Werror")
65200576Sroberto                .outdir(classes)
66200576Sroberto                .files(findJavaFiles(m1))
67280849Scy                .run(Task.Expect.SUCCESS)
68200576Sroberto                .writeAll()
69285169Scy                .getOutput(Task.OutputKind.DIRECT);
70200576Sroberto
71200576Sroberto        if (!log.isEmpty())
72200576Sroberto            throw new Exception("expected output not found: " + log);
73182007Sroberto    }
74200576Sroberto
75182007Sroberto}
76182007Sroberto