langtools/test/tools/javac/modules/MOptionTest.java
author jjg
Wed, 10 Aug 2016 15:47:46 -0700
changeset 40308 274367a99f98
parent 37758 3ecf9b414e05
child 42822 a84956e7ee4d
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) 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
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    26
 * @bug 8146946
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    27
 * @summary implement javac -m option
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
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    32
 * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    33
 * @run main MOptionTest
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    34
 */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    35
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.nio.file.attribute.FileTime;
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    39
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    40
import toolbox.JavacTask;
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    41
import toolbox.Task;
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    42
import toolbox.ToolBox;
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    43
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    44
public class MOptionTest extends ModuleTestBase {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    45
    public static void main(String... args) throws Exception {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    46
        new MOptionTest().runTests();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    47
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    48
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    49
    @Test
37758
3ecf9b414e05 8155774: move code from ModuleTestBase to toolbox
jjg
parents: 36778
diff changeset
    50
    public void testOneModule(Path base) throws Exception {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    51
        Path src = base.resolve("src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    52
        Path m1 = src.resolve("m1");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    53
        Path build = base.resolve("build");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    54
        Files.createDirectories(build);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    55
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    56
        tb.writeJavaFiles(m1,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    57
                "module m1 {}",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    58
                "package test; public class Test {}");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    59
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    60
        new JavacTask(tb)
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37758
diff changeset
    61
                .options("-m", "m1", "--module-source-path", src.toString(), "-d", build.toString())
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    62
                .run(Task.Expect.SUCCESS)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    63
                .writeAll();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    64
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    65
        Path moduleInfoClass = build.resolve("m1/module-info.class");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    66
        Path testTestClass = build.resolve("m1/test/Test.class");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    67
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    68
        FileTime moduleInfoTimeStamp = Files.getLastModifiedTime(moduleInfoClass);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    69
        FileTime testTestTimeStamp = Files.getLastModifiedTime(testTestClass);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    70
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    71
        Path moduleInfo = m1.resolve("module-info.java");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    72
        if (moduleInfoTimeStamp.compareTo(Files.getLastModifiedTime(moduleInfo)) < 0) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    73
            throw new AssertionError("Classfiles too old!");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    74
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    75
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    76
        Path testTest = m1.resolve("test/Test.java");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    77
        if (testTestTimeStamp.compareTo(Files.getLastModifiedTime(testTest)) < 0) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    78
            throw new AssertionError("Classfiles too old!");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    79
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    80
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    81
        Thread.sleep(2000); //timestamps
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    82
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    83
        new JavacTask(tb)
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37758
diff changeset
    84
                .options("-m", "m1", "--module-source-path", src.toString(), "-d", build.toString())
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    85
                .run(Task.Expect.SUCCESS)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    86
                .writeAll();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    87
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    88
        if (!moduleInfoTimeStamp.equals(Files.getLastModifiedTime(moduleInfoClass))) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    89
            throw new AssertionError("Classfile update!");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    90
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    91
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    92
        if (!testTestTimeStamp.equals(Files.getLastModifiedTime(testTestClass))) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    93
            throw new AssertionError("Classfile update!");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    94
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    95
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    96
        Thread.sleep(2000); //timestamps
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    97
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    98
        Files.setLastModifiedTime(testTest, FileTime.fromMillis(System.currentTimeMillis()));
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    99
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   100
        new JavacTask(tb)
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37758
diff changeset
   101
                .options("-m", "m1", "--module-source-path", src.toString(), "-d", build.toString())
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   102
                .run(Task.Expect.SUCCESS)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   103
                .writeAll();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   104
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   105
        if (!moduleInfoTimeStamp.equals(Files.getLastModifiedTime(moduleInfoClass))) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   106
            throw new AssertionError("Classfile update!");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   107
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   108
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   109
        if (Files.getLastModifiedTime(testTestClass).compareTo(Files.getLastModifiedTime(testTest)) < 0) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   110
            throw new AssertionError("Classfiles too old!");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   111
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   112
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   113
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   114
    @Test
37758
3ecf9b414e05 8155774: move code from ModuleTestBase to toolbox
jjg
parents: 36778
diff changeset
   115
    public void testNoOutputDir(Path base) throws Exception {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   116
        Path src = base.resolve("src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   117
        Path m1 = src.resolve("m1");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   118
        Path build = base.resolve("build");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   119
        Files.createDirectories(build);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   120
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   121
        tb.writeJavaFiles(m1,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   122
                "module m1 {}",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   123
                "package test; public class Test {}");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   124
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   125
        String log = new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   126
                .options("-XDrawDiagnostics",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   127
                    "-m", "m1",
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37758
diff changeset
   128
                    "--module-source-path", src.toString())
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
                .getOutput(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   132
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   133
        if (!log.contains("- compiler.err.output.dir.must.be.specified.with.dash.m.option"))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   134
            throw new Exception("expected output not found");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   135
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   136
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   137
    @Test
37758
3ecf9b414e05 8155774: move code from ModuleTestBase to toolbox
jjg
parents: 36778
diff changeset
   138
    public void testNoModuleSourcePath(Path base) throws Exception {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   139
        Path src = base.resolve("src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   140
        Path m1 = src.resolve("m1");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   141
        Path build = base.resolve("build");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   142
        Files.createDirectories(build);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   143
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   144
        tb.writeJavaFiles(m1,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   145
                "module m1 {}",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   146
                "package test; public class Test {}");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   147
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   148
        String log = new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   149
                .options("-XDrawDiagnostics",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   150
                        "-m", "m1",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   151
                        "-d", build.toString())
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   152
                .run(Task.Expect.FAIL)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   153
                .writeAll()
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   154
                .getOutput(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   155
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   156
        if (!log.contains("- compiler.err.modulesourcepath.must.be.specified.with.dash.m.option"))
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
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   160
    @Test
37758
3ecf9b414e05 8155774: move code from ModuleTestBase to toolbox
jjg
parents: 36778
diff changeset
   161
    public void testMultiModule(Path base) throws Exception {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   162
        Path src = base.resolve("src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   163
        Path m1 = src.resolve("m1");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   164
        Path m2 = src.resolve("m2");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   165
        Path build = base.resolve("build");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   166
        Files.createDirectories(build);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   167
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   168
        tb.writeJavaFiles(m1,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   169
                "module m1 {}",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   170
                "package p1; public class C1 {}");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   171
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   172
        tb.writeJavaFiles(m2,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   173
                "module m2 {}",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   174
                "package p2; public class C2 {}");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   175
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   176
        new JavacTask(tb)
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37758
diff changeset
   177
                .options("-m", "m1,m2", "--module-source-path", src.toString(), "-d", build.toString())
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   178
                .run(Task.Expect.SUCCESS)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   179
                .writeAll();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   180
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   181
        Path m1ModuleInfoClass = build.resolve("m1/module-info.class");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   182
        Path classC1 = build.resolve("m1/p1/C1.class");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   183
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   184
        Path m2ModuleInfoClass = build.resolve("m2/module-info.class");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   185
        Path classC2 = build.resolve("m2/p2/C2.class");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   186
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   187
        FileTime m1ModuleInfoTimeStamp = Files.getLastModifiedTime(m1ModuleInfoClass);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   188
        FileTime C1TimeStamp = Files.getLastModifiedTime(classC1);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   189
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   190
        FileTime m2ModuleInfoTimeStamp = Files.getLastModifiedTime(m2ModuleInfoClass);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   191
        FileTime C2TimeStamp = Files.getLastModifiedTime(classC2);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   192
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   193
        Path m1ModuleInfo = m1.resolve("module-info.java");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   194
        Path m2ModuleInfo = m2.resolve("module-info.java");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   195
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   196
        if (m1ModuleInfoTimeStamp.compareTo(Files.getLastModifiedTime(m1ModuleInfo)) < 0) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   197
            throw new AssertionError("Classfiles too old!");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   198
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   199
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   200
        if (m2ModuleInfoTimeStamp.compareTo(Files.getLastModifiedTime(m2ModuleInfo)) < 0) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   201
            throw new AssertionError("Classfiles too old!");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   202
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   203
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   204
        Path C1Source = m1.resolve("p1/C1.java");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   205
        Path C2Source = m2.resolve("p2/C2.java");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   206
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   207
        if (C1TimeStamp.compareTo(Files.getLastModifiedTime(C1Source)) < 0) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   208
            throw new AssertionError("Classfiles too old!");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   209
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   210
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   211
        if (C2TimeStamp.compareTo(Files.getLastModifiedTime(C2Source)) < 0) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   212
            throw new AssertionError("Classfiles too old!");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   213
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   214
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   215
        Thread.sleep(2000); //timestamps
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   216
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   217
        new JavacTask(tb)
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37758
diff changeset
   218
                .options("-m", "m1,m2", "--module-source-path", src.toString(), "-d", build.toString())
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   219
                .run(Task.Expect.SUCCESS)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   220
                .writeAll();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   221
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   222
        if (!m1ModuleInfoTimeStamp.equals(Files.getLastModifiedTime(m1ModuleInfoClass))) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   223
            throw new AssertionError("Classfile update!");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   224
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   225
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   226
        if (!m2ModuleInfoTimeStamp.equals(Files.getLastModifiedTime(m2ModuleInfoClass))) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   227
            throw new AssertionError("Classfile update!");
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
        if (!C1TimeStamp.equals(Files.getLastModifiedTime(classC1))) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   231
            throw new AssertionError("Classfile update!");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   232
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   233
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   234
        if (!C2TimeStamp.equals(Files.getLastModifiedTime(classC2))) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   235
            throw new AssertionError("Classfile update!");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   236
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   237
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   238
        Thread.sleep(2000); //timestamps
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   239
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   240
        Files.setLastModifiedTime(C1Source, FileTime.fromMillis(System.currentTimeMillis()));
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   241
        Files.setLastModifiedTime(C2Source, FileTime.fromMillis(System.currentTimeMillis()));
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   242
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   243
        new JavacTask(tb)
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37758
diff changeset
   244
                .options("-m", "m1,m2", "--module-source-path", src.toString(), "-d", build.toString())
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   245
                .run(Task.Expect.SUCCESS)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   246
                .writeAll();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   247
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   248
        if (!m1ModuleInfoTimeStamp.equals(Files.getLastModifiedTime(m1ModuleInfoClass))) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   249
            throw new AssertionError("Classfile update!");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   250
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   251
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   252
        if (!m2ModuleInfoTimeStamp.equals(Files.getLastModifiedTime(m2ModuleInfoClass))) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   253
            throw new AssertionError("Classfile update!");
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
        if (Files.getLastModifiedTime(classC1).compareTo(Files.getLastModifiedTime(C1Source)) < 0) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   257
            throw new AssertionError("Classfiles too old!");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   258
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   259
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   260
        if (Files.getLastModifiedTime(classC2).compareTo(Files.getLastModifiedTime(C2Source)) < 0) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   261
            throw new AssertionError("Classfiles too old!");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   262
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   263
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   264
}