langtools/test/tools/javac/modules/GraphsTest.java
author jjg
Thu, 31 Mar 2016 15:20:50 -0700
changeset 36778 e04318f39f92
parent 36526 3b41f1c69604
child 37758 3ecf9b414e05
permissions -rw-r--r--
8152897: refactor ToolBox to allow reduced documented dependencies Reviewed-by: vromero
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     1
/*
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     4
 *
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     8
 *
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    13
 * accompanied this code).
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    14
 *
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    18
 *
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    21
 * questions.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    22
 */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    23
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    24
/*
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    25
 * @test
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    26
 * @summary tests for module graph resolution issues
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    27
 * @library /tools/lib
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    28
 * @modules
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    29
 *      jdk.compiler/com.sun.tools.javac.api
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    30
 *      jdk.compiler/com.sun.tools.javac.main
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    31
 * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask ModuleTestBase
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    32
 * @run main GraphsTest
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    33
 */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    34
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    35
import java.io.File;
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    36
import java.nio.file.Files;
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    37
import java.nio.file.Path;
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    38
import java.util.Arrays;
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    39
import java.util.List;
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    40
import java.util.regex.Pattern;
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    41
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    42
import toolbox.JarTask;
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    43
import toolbox.JavacTask;
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    44
import toolbox.Task;
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    45
import toolbox.ToolBox;
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    46
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    47
public class GraphsTest extends ModuleTestBase {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    48
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    49
    public static void main(String... args) throws Exception {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    50
        GraphsTest t = new GraphsTest();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    51
        t.runTests();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    52
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    53
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    54
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    55
     * Tests diamond graph with an automatic module added in.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    56
     * +-------------+          +--------------------+         +------------------+
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    57
     * | module M    |          | module N           |         | module O         |
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    58
     * |             | ----->   |                    | --->    |                  |  --> J.jar
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    59
     * | require N   |          | requires public  O |         |                  |
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    60
     * | require L   |          |                    |         +------------------+
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    61
     * +-------------+          +--------------------+                  ^
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    62
     *       |                                                          |
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    63
     *       |                  +--------------------+                  |
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    64
     *       ------------------>| module L           |                  |
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    65
     *                          |                    |------------------
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    66
     *                          | requires public O  |
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    67
     *                          |                    |
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    68
     *                          +--------------------+
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    69
     *
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    70
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    71
    @Test
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    72
    void diamond(Path base) throws Exception {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    73
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    74
        Path modules = Files.createDirectories(base.resolve("modules"));
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    75
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    76
        new ModuleBuilder("J")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    77
                .exports("openJ")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    78
                .classes("package openJ; public class J { }")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    79
                .classes("package closedJ; public class J { }")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    80
                .build(base.resolve("jar"));
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    81
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    82
        Path jarModules = Files.createDirectories(base.resolve("jarModules"));
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    83
        Path jar = jarModules.resolve("J.jar");
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    84
        new JarTask(tb, jar)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    85
                .baseDir(base.resolve("jar/J"))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    86
                .files(".")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    87
                .run()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    88
                .writeAll();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    89
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    90
        new ModuleBuilder("O")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    91
                .exports("openO")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    92
                .requiresPublic("J", jarModules)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    93
                .classes("package openO; public class O { openJ.J j; }")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    94
                .classes("package closedO; public class O { }")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    95
                .build(modules);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    96
        new ModuleBuilder("N")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    97
                .requiresPublic("O", modules, jarModules)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    98
                .exports("openN")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    99
                .classes("package openN; public class N { }")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   100
                .classes("package closedN; public class N { }")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   101
                .build(modules);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   102
        new ModuleBuilder("L")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   103
                .requiresPublic("O", modules, jarModules)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   104
                .exports("openL")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   105
                .classes("package openL; public class L { }")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   106
                .classes("package closedL; public class L { }")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   107
                .build(modules);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   108
        ModuleBuilder m = new ModuleBuilder("M");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   109
        //positive case
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   110
        Path positiveSrc = m
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   111
                .requires("N", modules)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   112
                .requires("L", modules)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   113
                .classes("package p; public class Positive { openO.O o; openN.N n; openL.L l; }")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   114
                .write(base.resolve("positiveSrc"));
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   115
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   116
        new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   117
                .options("-XDrawDiagnostics", "-mp", modules + File.pathSeparator + jarModules)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   118
                .outdir(Files.createDirectories(base.resolve("positive")))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   119
                .files(findJavaFiles(positiveSrc))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   120
                .run()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   121
                .writeAll();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   122
        //negative case
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   123
        Path negativeSrc = m.classes("package p; public class Negative { closedO.O o; closedN.N n; closedL.L l; }")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   124
                .write(base.resolve("negativeSrc"));
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   125
        List<String> log = new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   126
                .options("-XDrawDiagnostics", "-mp", modules + File.pathSeparator + jarModules)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   127
                .outdir(Files.createDirectories(base.resolve("negative")))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   128
                .files(findJavaFiles(negativeSrc))
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   129
                .run(Task.Expect.FAIL)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   130
                .writeAll()
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   131
                .getOutputLines(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   132
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   133
        List<String> expected = Arrays.asList(
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   134
                "Negative.java:1:43: compiler.err.doesnt.exist: closedO",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   135
                "Negative.java:1:56: compiler.err.doesnt.exist: closedN",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   136
                "Negative.java:1:69: compiler.err.doesnt.exist: closedL");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   137
        if (!log.containsAll(expected)) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   138
            throw new Exception("Expected output not found");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   139
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   140
        //multi module mode
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   141
        m.write(modules);
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   142
        List<String> out = new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   143
                .options("-XDrawDiagnostics",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   144
                        "-modulesourcepath", modules + "/*/src",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   145
                        "-mp", jarModules.toString()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   146
                )
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   147
                .outdir(Files.createDirectories(base.resolve("negative")))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   148
                .files(findJavaFiles(modules))
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   149
                .run(Task.Expect.FAIL)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   150
                .writeAll()
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   151
                .getOutputLines(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   152
        expected = Arrays.asList(
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   153
                "Negative.java:1:43: compiler.err.not.def.access.package.cant.access: closedO.O, closedO",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   154
                "Negative.java:1:56: compiler.err.not.def.access.package.cant.access: closedN.N, closedN",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   155
                "Negative.java:1:69: compiler.err.not.def.access.package.cant.access: closedL.L, closedL");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   156
        if (!out.containsAll(expected)) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   157
            throw new Exception("Expected output not found");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   158
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   159
        //checks if the output does not contain messages about exported packages.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   160
        Pattern regex = Pattern.compile("compiler\\.err.*(openO\\.O|openN\\.N|openL\\.L)");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   161
        for (String s : out) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   162
            if (regex.matcher(s).find()) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   163
                throw new Exception("Unexpected output: " + s);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   164
            }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   165
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   166
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   167
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   168
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   169
     * Tests graph where module M reexport package of N, but N export the package only to M.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   170
     *
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   171
    +-------------+        +--------------------+        +---------------+
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   172
    | module L    |        | module M           |        | module N      |
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   173
    |             | -----> |                    | -----> |               |
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   174
    |  requires M |        |  requires public N |        | exports P to M|
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   175
    +-------------+        |                    |        +---------------+
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   176
                           +--------------------+
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   177
    */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   178
    @Test
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   179
    public void reexportOfQualifiedExport(Path base) throws Exception {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   180
        Path modules = base.resolve("modules");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   181
        new ModuleBuilder("M")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   182
                .requiresPublic("N")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   183
                .write(modules);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   184
        new ModuleBuilder("N")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   185
                .exportsTo("pack", "M")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   186
                .classes("package pack; public class Clazz { }")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   187
                .write(modules);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   188
        new ModuleBuilder("L")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   189
                .requires("M")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   190
                .classes("package p; public class A { A(pack.Clazz cl){} } ")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   191
                .write(modules);
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   192
        String log = new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   193
                .options("-XDrawDiagnostics",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   194
                        "-modulesourcepath", modules + "/*/src")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   195
                .outdir(Files.createDirectories(base.resolve("negative")))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   196
                .files(findJavaFiles(modules))
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   197
                .run(Task.Expect.FAIL)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   198
                .writeAll()
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   199
                .getOutput(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   200
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   201
        String expected = "A.java:1:35: compiler.err.not.def.access.package.cant.access: pack.Clazz, pack";
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   202
        if (!log.contains(expected)) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   203
            throw new Exception("Expected output not found");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   204
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   205
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   206
}