langtools/test/tools/sjavac/CompileCircularSources.java
changeset 28276 ec66954fa850
child 30730 d3ce7619db2c
equal deleted inserted replaced
28275:cfbf3c5d12dd 28276:ec66954fa850
       
     1 /*
       
     2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Oracle designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Oracle in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  */
       
    25 
       
    26 /*
       
    27  * @test
       
    28  * @summary Verify that circular sources split on multiple cores can be compiled
       
    29  * @bug 8054689
       
    30  * @author Fredrik O
       
    31  * @author sogoel (rewrite)
       
    32  * @library /tools/lib
       
    33  * @build Wrapper ToolBox
       
    34  * @run main Wrapper CompileCircularSources
       
    35  */
       
    36 
       
    37 import java.util.*;
       
    38 import java.nio.file.*;
       
    39 
       
    40 public class CompileCircularSources extends SJavacTester {
       
    41     public static void main(String... args) throws Exception {
       
    42         CompileCircularSources ccs = new CompileCircularSources();
       
    43         ccs.test();
       
    44     }
       
    45 
       
    46     void test() throws Exception {
       
    47         Files.createDirectory(BIN);
       
    48         clean(GENSRC, BIN);
       
    49 
       
    50         Map<String,Long> previous_bin_state = collectState(BIN);
       
    51 
       
    52         ToolBox tb = new ToolBox();
       
    53         tb.writeFile(GENSRC.resolve("alfa/omega/A.java"),
       
    54                  "package alfa.omega; public class A { beta.B b; }");
       
    55         tb.writeFile(GENSRC.resolve("beta/B.java"),
       
    56                  "package beta; public class B { gamma.C c; }");
       
    57         tb.writeFile(GENSRC.resolve("gamma/C.java"),
       
    58                  "package gamma; public class C { alfa.omega.A a; }");
       
    59 
       
    60         compile("gensrc", "-d", "bin", "-h", "headers", "-j", "3",
       
    61                 SERVER_ARG,"--log=debug");
       
    62         Map<String,Long> new_bin_state = collectState(BIN);
       
    63         verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state,
       
    64                                      "bin/alfa/omega/A.class",
       
    65                                      "bin/beta/B.class",
       
    66                                      "bin/gamma/C.class",
       
    67                                      "bin/javac_state");
       
    68         clean(GENSRC, BIN);
       
    69     }
       
    70 }