langtools/test/tools/javac/modules/AllDefaultTest.java
author jjg
Tue, 22 Nov 2016 15:57:32 -0800
changeset 42269 24a766b7c106
child 43863 7e9df8be8693
permissions -rw-r--r--
8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT" Reviewed-by: mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42269
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
     1
/*
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
     4
 *
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
     8
 *
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    13
 * accompanied this code).
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    14
 *
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    18
 *
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    21
 * questions.
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    22
 */
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    23
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    24
/**
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    25
 * @test
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    26
 * @bug 0000000
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    27
 * @summary Test use of ALL-DEFAULT token
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    28
 * @library /tools/lib
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    29
 * @modules
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    30
 *      jdk.compiler/com.sun.tools.javac.api
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    31
 *      jdk.compiler/com.sun.tools.javac.main
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    32
 * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask toolbox.JavaTask ModuleTestBase
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    33
 * @run main AllDefaultTest
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    34
 */
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    35
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    36
import java.nio.file.Path;
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    37
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    38
import toolbox.JavacTask;
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    39
import toolbox.Task;
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    40
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    41
public class AllDefaultTest extends ModuleTestBase {
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    42
    public static void main(String... args) throws Exception {
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    43
        AllDefaultTest t = new AllDefaultTest();
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    44
        t.runTests();
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    45
    }
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    46
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    47
    @Test
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    48
    public void testCompileTime_notAllowed(Path base) throws Exception {
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    49
        tb.writeJavaFiles(base, "class C { }");
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    50
        String out = new JavacTask(tb)
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    51
                .options("-XDrawDiagnostics",
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    52
                        "--add-modules=ALL-DEFAULT")
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    53
                .files(tb.findJavaFiles(base))
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    54
                .run(Task.Expect.FAIL)
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    55
                .writeAll()
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    56
                .getOutput(Task.OutputKind.DIRECT);
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    57
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    58
        if (!out.contains("- compiler.err.bad.name.for.option: --add-modules, ALL-DEFAULT")) {
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    59
            error("expected text not found");
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    60
        }
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    61
    }
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    62
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    63
    @Test
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    64
    public void testRuntimeTime_ignored_1(Path base) throws Exception {
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    65
        tb.writeJavaFiles(base, "class C { }");
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    66
        new JavacTask(tb, Task.Mode.EXEC)
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    67
                .options("-XDrawDiagnostics",
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    68
                        "-J--add-modules=ALL-DEFAULT",
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    69
                        "--inherit-runtime-environment")
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    70
                .files(tb.findJavaFiles(base))
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    71
                .run()
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    72
                .writeAll();
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    73
    }
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    74
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    75
    @Test
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    76
    public void testRuntimeTime_ignored_2(Path base) throws Exception {
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    77
        tb.writeJavaFiles(base, "class C { }");
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    78
        new JavacTask(tb, Task.Mode.EXEC)
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    79
                .options("-XDrawDiagnostics",
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    80
                        "-J--add-modules=jdk.compiler",
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    81
                        "--inherit-runtime-environment")
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    82
                .files(tb.findJavaFiles(base))
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    83
                .run()
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    84
                .writeAll();
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    85
    }
24a766b7c106 8164590: javac --inherit-runtime-environment fails with "cannot find modules: ALL-DEFAULT"
jjg
parents:
diff changeset
    86
}