langtools/test/tools/javac/modules/ModuleInfoTest.java
author jjg
Wed, 10 Aug 2016 15:47:46 -0700
changeset 40308 274367a99f98
parent 38916 d118cb2cffab
child 42407 f3702cff2933
permissions -rw-r--r--
8136930: Simplify use of module-system options by custom launchers 8160489: Multiple -Xpatch lines ignored by javac 8156998: javac should support new option -XinheritRuntimeEnvironment Reviewed-by: jlahoda, ksrini
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     1
/*
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
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
38916
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
    26
 * @bug 8158123
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    27
 * @summary tests for module declarations
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    28
 * @library /tools/lib
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    29
 * @modules
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    30
 *      jdk.compiler/com.sun.tools.javac.api
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    31
 *      jdk.compiler/com.sun.tools.javac.main
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    32
 *      jdk.jdeps/com.sun.tools.javap
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    33
 * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    34
 * @run main ModuleInfoTest
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    35
 */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    36
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    37
import java.nio.file.Files;
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    38
import java.nio.file.Path;
38916
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
    39
import java.util.Arrays;
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    40
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    41
import toolbox.JavacTask;
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    42
import toolbox.Task;
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    43
import toolbox.ToolBox;
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    44
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    45
public class ModuleInfoTest extends ModuleTestBase {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    46
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    47
    public static void main(String... args) throws Exception {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    48
        ModuleInfoTest t = new ModuleInfoTest();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    49
        t.runTests();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    50
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    51
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    52
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    53
     * Check error message if module declaration not in module-info.java.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    54
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    55
    @Test
37758
3ecf9b414e05 8155774: move code from ModuleTestBase to toolbox
jjg
parents: 36778
diff changeset
    56
    public void testModuleDeclNotInModuleJava(Path base) throws Exception {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    57
        Path src = base.resolve("src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    58
        tb.writeFile(src.resolve("M.java"), "module M { }");
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    59
        String log = new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    60
                .options("-XDrawDiagnostics")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    61
                .files(findJavaFiles(src))
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    62
                .run(Task.Expect.FAIL)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    63
                .writeAll()
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    64
                .getOutput(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    65
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    66
        if (!log.contains("M.java:1:1: compiler.err.module.decl.sb.in.module-info.java"))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    67
            throw new Exception("expected output not found");
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
     * Verify that a package private class can be put in module-info.java.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    72
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    73
    @Test
37758
3ecf9b414e05 8155774: move code from ModuleTestBase to toolbox
jjg
parents: 36778
diff changeset
    74
    public void testNotModuleDeclInModuleJava_1(Path base) throws Exception {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    75
        Path src = base.resolve("src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    76
        tb.writeFile(src.resolve("module-info.java"), "class C { }");
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    77
        new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    78
                .options("-XDrawDiagnostics")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    79
                .files(findJavaFiles(src))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    80
                .run()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    81
                .writeAll();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    82
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    83
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    84
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    85
     * Verify that a public class cannot be put in module-info.java.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    86
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    87
    @Test
37758
3ecf9b414e05 8155774: move code from ModuleTestBase to toolbox
jjg
parents: 36778
diff changeset
    88
    public void testNotModuleDeclInModuleJava_2(Path base) throws Exception {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    89
        Path src = base.resolve("src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    90
        tb.writeFile(src.resolve("module-info.java"), "public class C { }");
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    91
        String log = new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    92
                .options("-XDrawDiagnostics")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    93
                .files(findJavaFiles(src))
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    94
                .run(Task.Expect.FAIL)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    95
                .writeAll()
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    96
                .getOutput(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    97
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    98
        if (!log.contains("module-info.java:1:8: compiler.err.class.public.should.be.in.file: C"))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    99
            throw new Exception("expected output not found");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   100
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   101
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   102
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   103
     * Verify that only one module decl can be put in module-info.java.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   104
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   105
    @Test
37758
3ecf9b414e05 8155774: move code from ModuleTestBase to toolbox
jjg
parents: 36778
diff changeset
   106
    public void testSingleModuleDecl(Path base) throws Exception {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   107
        Path src = base.resolve("src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   108
        tb.writeJavaFiles(src, "module M1 { } /*...*/ module M2 { }");
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   109
        String log = new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   110
                .options("-XDrawDiagnostics")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   111
                .files(findJavaFiles(src))
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   112
                .run(Task.Expect.FAIL)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   113
                .writeAll()
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   114
                .getOutput(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   115
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   116
        if (!log.contains("module-info.java:1:14: compiler.err.expected: token.end-of-input"))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   117
            throw new Exception("expected output not found");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   118
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   119
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   120
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   121
     * Verify that missing requires are reported.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   122
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   123
    @Test
37758
3ecf9b414e05 8155774: move code from ModuleTestBase to toolbox
jjg
parents: 36778
diff changeset
   124
    public void testRequiresNotFound(Path base) throws Exception {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   125
        Path src = base.resolve("src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   126
        tb.writeJavaFiles(src, "module M1 { requires M2; }");
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   127
        String log = new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   128
                .options("-XDrawDiagnostics")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   129
                .files(findJavaFiles(src))
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   130
                .run(Task.Expect.FAIL)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   131
                .writeAll()
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   132
                .getOutput(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   133
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   134
        if (!log.contains("module-info.java:1:22: compiler.err.module.not.found: M2"))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   135
            throw new Exception("expected output not found");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   136
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   137
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   138
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   139
     * Verify that missing exports are reported.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   140
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   141
    @Test
37758
3ecf9b414e05 8155774: move code from ModuleTestBase to toolbox
jjg
parents: 36778
diff changeset
   142
    public void testExportsNotFound(Path base) throws Exception {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   143
        Path src = base.resolve("src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   144
        tb.writeJavaFiles(src, "module M1 { exports p to M2; }");
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   145
        String log = new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   146
                .options("-XDrawDiagnostics")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   147
                .files(findJavaFiles(src))
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   148
                .run(Task.Expect.FAIL)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   149
                .writeAll()
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   150
                .getOutput(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   151
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   152
        if (!log.contains("module-info.java:1:26: compiler.err.module.not.found: M2"))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   153
            throw new Exception("expected output not found");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   154
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   155
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   156
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   157
     * Verify that a simple loop is detected.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   158
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   159
    @Test
37758
3ecf9b414e05 8155774: move code from ModuleTestBase to toolbox
jjg
parents: 36778
diff changeset
   160
    public void testRequiresSelf(Path base) throws Exception {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   161
        Path src = base.resolve("src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   162
        tb.writeJavaFiles(src, "module M { requires M; }");
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   163
        String log = new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   164
                .options("-XDrawDiagnostics")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   165
                .files(findJavaFiles(src))
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   166
                .run(Task.Expect.FAIL)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   167
                .writeAll()
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   168
                .getOutput(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   169
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   170
        if (!log.contains("module-info.java:1:21: compiler.err.cyclic.requires: M"))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   171
            throw new Exception("expected output not found");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   172
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   173
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   174
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   175
     * Verify that a multi-module loop is detected.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   176
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   177
    @Test
37758
3ecf9b414e05 8155774: move code from ModuleTestBase to toolbox
jjg
parents: 36778
diff changeset
   178
    public void testRequiresLoop(Path base) throws Exception {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   179
        Path src = base.resolve("src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   180
        Path src_m1 = src.resolve("m1");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   181
        tb.writeFile(src_m1.resolve("module-info.java"), "module m1 { requires m2; }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   182
        Path src_m2 = src.resolve("m2");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   183
        tb.writeFile(src_m2.resolve("module-info.java"), "module m2 { requires m3; }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   184
        Path src_m3 = src.resolve("m3");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   185
        tb.writeFile(src_m3.resolve("module-info.java"), "module m3 { requires m1; }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   186
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   187
        Path classes = base.resolve("classes");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   188
        Files.createDirectories(classes);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   189
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   190
        String log = new JavacTask(tb)
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 38916
diff changeset
   191
                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   192
                .outdir(classes)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   193
                .files(findJavaFiles(src))
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   194
                .run(Task.Expect.FAIL)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   195
                .writeAll()
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   196
                .getOutput(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   197
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   198
        if (!log.contains("module-info.java:1:22: compiler.err.cyclic.requires: m3"))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   199
            throw new Exception("expected output not found");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   200
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   201
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   202
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   203
     * Verify that a multi-module loop is detected.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   204
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   205
    @Test
37758
3ecf9b414e05 8155774: move code from ModuleTestBase to toolbox
jjg
parents: 36778
diff changeset
   206
    public void testRequiresPublicLoop(Path base) throws Exception {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   207
        Path src = base.resolve("src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   208
        Path src_m1 = src.resolve("m1");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   209
        tb.writeFile(src_m1.resolve("module-info.java"), "module m1 { requires m2; }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   210
        Path src_m2 = src.resolve("m2");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   211
        tb.writeFile(src_m2.resolve("module-info.java"), "module m2 { requires public m3; }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   212
        Path src_m3 = src.resolve("m3");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   213
        tb.writeFile(src_m3.resolve("module-info.java"), "module m3 { requires m1; }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   214
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   215
        Path classes = base.resolve("classes");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   216
        Files.createDirectories(classes);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   217
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   218
        String log = new JavacTask(tb)
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 38916
diff changeset
   219
                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   220
                .outdir(classes)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   221
                .files(findJavaFiles(src))
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   222
                .run(Task.Expect.FAIL)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   223
                .writeAll()
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   224
                .getOutput(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   225
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   226
        if (!log.contains("module-info.java:1:29: compiler.err.cyclic.requires: m3"))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   227
            throw new Exception("expected output not found");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   228
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   229
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   230
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   231
     * Verify that duplicate requires are detected.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   232
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   233
    @Test
37758
3ecf9b414e05 8155774: move code from ModuleTestBase to toolbox
jjg
parents: 36778
diff changeset
   234
    public void testDuplicateRequires(Path base) throws Exception {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   235
        Path src = base.resolve("src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   236
        Path src_m1 = src.resolve("m1");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   237
        tb.writeFile(src_m1.resolve("module-info.java"), "module m1 { }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   238
        Path src_m2 = src.resolve("m2");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   239
        tb.writeFile(src_m2.resolve("module-info.java"), "module m2 { requires m1; requires m1; }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   240
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   241
        Path classes = base.resolve("classes");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   242
        Files.createDirectories(classes);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   243
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   244
        String log = new JavacTask(tb)
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 38916
diff changeset
   245
                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   246
                .outdir(classes)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   247
                .files(findJavaFiles(src))
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   248
                .run(Task.Expect.FAIL)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   249
                .writeAll()
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   250
                .getOutput(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   251
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   252
        if (!log.contains("module-info.java:1:35: compiler.err.duplicate.requires: m1"))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   253
            throw new Exception("expected output not found");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   254
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   255
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   256
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   257
     * Verify that duplicate exported packages are detected.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   258
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   259
    @Test
37758
3ecf9b414e05 8155774: move code from ModuleTestBase to toolbox
jjg
parents: 36778
diff changeset
   260
    public void testDuplicateExports_packages(Path base) throws Exception {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   261
        Path src = base.resolve("src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   262
        tb.writeJavaFiles(src, "module m1 { exports p; exports p; }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   263
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   264
        Path classes = base.resolve("classes");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   265
        Files.createDirectories(classes);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   266
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   267
        String log = new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   268
                .options("-XDrawDiagnostics")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   269
                .outdir(classes)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   270
                .files(findJavaFiles(src))
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   271
                .run(Task.Expect.FAIL)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   272
                .writeAll()
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   273
                .getOutput(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   274
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   275
        if (!log.contains("module-info.java:1:32: compiler.err.duplicate.exports: p"))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   276
            throw new Exception("expected output not found");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   277
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   278
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   279
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   280
     * Verify that duplicate exported packages are detected.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   281
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   282
    @Test
37758
3ecf9b414e05 8155774: move code from ModuleTestBase to toolbox
jjg
parents: 36778
diff changeset
   283
    public void testDuplicateExports_packages2(Path base) throws Exception {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   284
        Path src = base.resolve("src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   285
        tb.writeJavaFiles(src.resolve("m1"), "module m1 { exports p; exports p to m2; }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   286
        tb.writeJavaFiles(src.resolve("m2"), "module m2 { }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   287
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   288
        Path classes = base.resolve("classes");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   289
        Files.createDirectories(classes);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   290
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   291
        String log = new JavacTask(tb)
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 38916
diff changeset
   292
                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   293
                .outdir(classes)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   294
                .files(findJavaFiles(src))
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   295
                .run(Task.Expect.FAIL)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   296
                .writeAll()
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   297
                .getOutput(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   298
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   299
        if (!log.contains("module-info.java:1:32: compiler.err.duplicate.exports: p"))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   300
            throw new Exception("expected output not found");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   301
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   302
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   303
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   304
     * Verify that duplicate exported packages are detected.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   305
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   306
    @Test
37758
3ecf9b414e05 8155774: move code from ModuleTestBase to toolbox
jjg
parents: 36778
diff changeset
   307
    public void testDuplicateExports_modules(Path base) throws Exception {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   308
        Path src = base.resolve("src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   309
        Path src_m1 = src.resolve("m1");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   310
        tb.writeFile(src_m1.resolve("module-info.java"), "module m1 { }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   311
        Path src_m2 = src.resolve("m2");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   312
        tb.writeFile(src_m2.resolve("module-info.java"), "module m2 { exports p to m1, m1; }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   313
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   314
        Path classes = base.resolve("classes");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   315
        Files.createDirectories(classes);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   316
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   317
        String log = new JavacTask(tb)
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 38916
diff changeset
   318
                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   319
                .outdir(classes)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   320
                .files(findJavaFiles(src))
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   321
                .run(Task.Expect.FAIL)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   322
                .writeAll()
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   323
                .getOutput(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   324
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   325
        if (!log.contains("module-info.java:1:30: compiler.err.duplicate.exports: m1"))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   326
            throw new Exception("expected output not found");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   327
    }
38916
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   328
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   329
    /**
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   330
     * Verify that annotations are not permitted at
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   331
     * any of the module names or the package names.
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   332
     */
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   333
    @Test
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   334
    public void testAnnotations(Path base) throws Exception {
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   335
        Path src = base.resolve("src");
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   336
        Path src_m1 = src.resolve("m1.sub");
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   337
        Path classes = base.resolve("classes");
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   338
        Files.createDirectories(classes);
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   339
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   340
        String code = "module @m1.@sub { " +
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   341
                "requires @p1.@p2; " +
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   342
                "exports @p1.@p2; " +
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   343
                "exports @p1.@p2 to @m2.@sub; " +
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   344
                "exports @p1.@p2 to @m2.@sub, @m3.@sub; " +
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   345
                "uses @p1.@Interface; " +
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   346
                "provides @p1.@Interface with @p2.@Concrete; " +
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   347
                "}";
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   348
        String[] splittedCode = code.split("@");
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   349
        int length = splittedCode.length;
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   350
        String anno = "@Anno ";
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   351
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   352
        for (int i = 1; i < length; i++) {
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   353
            String preAnno = String.join("", Arrays.copyOfRange(splittedCode, 0, i));
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   354
            String postAnno = String.join("", Arrays.copyOfRange(splittedCode, i, length));
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   355
            String moduleInfo = preAnno + anno + postAnno;
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   356
            tb.writeFile(src_m1.resolve("module-info.java"), moduleInfo);
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   357
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   358
            String log = new JavacTask(tb)
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 38916
diff changeset
   359
                    .options("-XDrawDiagnostics", "--module-source-path", src.toString())
38916
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   360
                    .outdir(classes)
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   361
                    .files(findJavaFiles(src))
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   362
                    .run(Task.Expect.FAIL)
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   363
                    .writeAll()
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   364
                    .getOutput(Task.OutputKind.DIRECT);
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   365
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   366
            if (!log.matches("(?s)^module\\-info\\.java:\\d+:\\d+: compiler\\.err\\.expected: token\\.identifier.*"))
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   367
                throw new Exception("expected output not found");
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   368
        }
d118cb2cffab 8158123: NPE when the annotations is used in export-to of module-info
shinyafox
parents: 37758
diff changeset
   369
    }
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   370
}