langtools/test/tools/sjavac/CompileExcludingDependency.java
author amurillo
Thu, 13 Aug 2015 15:50:52 -0700
changeset 32224 dae855d05f6c
parent 31115 8d8e98052d5d
child 32337 c9d3ab9f601c
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28276
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
     1
/*
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 28276
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
28276
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
     4
 *
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    10
 *
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    15
 * accompanied this code).
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    16
 *
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    20
 *
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    23
 * questions.
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    24
 */
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    25
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    26
/*
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    27
 * @test
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    28
 * @summary Tests compiling class A that depends on class B without compiling class B
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    29
 * @bug 8054689
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    30
 * @author Fredrik O
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    31
 * @author sogoel (rewrite)
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    32
 * @library /tools/lib
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 28276
diff changeset
    33
 * @modules jdk.compiler/com.sun.tools.javac.api
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 28276
diff changeset
    34
 *          jdk.compiler/com.sun.tools.javac.file
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 28276
diff changeset
    35
 *          jdk.compiler/com.sun.tools.javac.main
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 28276
diff changeset
    36
 *          jdk.compiler/com.sun.tools.sjavac
28276
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    37
 * @build Wrapper ToolBox
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    38
 * @run main Wrapper CompileExcludingDependency
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    39
 */
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    40
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    41
import java.util.*;
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    42
import java.nio.file.*;
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    43
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    44
public class CompileExcludingDependency extends SJavacTester {
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    45
    public static void main(String... args) throws Exception {
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    46
        CompileExcludingDependency ced = new CompileExcludingDependency();
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    47
        ced.test();
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    48
    }
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    49
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    50
    // Verify that excluding classes from compilation but not from linking works
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    51
    void test() throws Exception {
31115
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents: 30730
diff changeset
    52
        clean(TEST_ROOT);
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents: 30730
diff changeset
    53
        Files.createDirectories(BIN);
28276
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    54
        clean(GENSRC,BIN);
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    55
        Map<String,Long> previous_bin_state = collectState(BIN);
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    56
        ToolBox tb = new ToolBox();
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    57
        tb.writeFile(GENSRC.resolve("alfa/omega/A.java"),
31115
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents: 30730
diff changeset
    58
                     "package alfa.omega; public class A { beta.B b; }");
28276
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    59
        tb.writeFile(GENSRC.resolve("beta/B.java"),
31115
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents: 30730
diff changeset
    60
                     "package beta; public class B { }");
28276
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    61
31115
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents: 30730
diff changeset
    62
        compile("-x", "beta",
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents: 30730
diff changeset
    63
                "-src", GENSRC.toString(),
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents: 30730
diff changeset
    64
                "-x", "alfa/omega",
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents: 30730
diff changeset
    65
                "-sourcepath", GENSRC.toString(),
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents: 30730
diff changeset
    66
                "-d", BIN.toString(),
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents: 30730
diff changeset
    67
                SERVER_ARG);
28276
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    68
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    69
        Map<String,Long> new_bin_state = collectState(BIN);
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    70
        verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state,
31115
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents: 30730
diff changeset
    71
                                     BIN + "/alfa/omega/A.class",
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents: 30730
diff changeset
    72
                                     BIN + "/javac_state");
28276
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    73
        clean(GENSRC, BIN);
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    74
    }
ec66954fa850 8054689: Split large SJavac.java test source into multiple files
sogoel
parents:
diff changeset
    75
}