langtools/test/tools/sjavac/PackagePathMismatch.java
author vasya
Mon, 14 Dec 2015 20:18:19 +0100
changeset 34752 9c262a013456
parent 33554 d29aff18b2f6
child 35356 e919fd8db52c
permissions -rw-r--r--
8145342: Some copyright notices are inconsistently and ill formatted Summary: Adjusted formatting of copyright notices. Reviewed-by: darcy, alundblad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26992
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
     1
/*
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 26992
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
26992
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
     4
 *
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
32337
c9d3ab9f601c 8133671: langtools tests have bad license
alundblad
parents: 30730
diff changeset
     7
 * published by the Free Software Foundation.
26992
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
     8
 *
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    13
 * accompanied this code).
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    14
 *
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    18
 *
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    21
 * questions.
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    22
 */
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    23
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    24
/*
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    25
 * @test
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    26
 * @bug 8059349
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    27
 * @summary This test makes sure file paths matches package declarations
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    28
 * @library /tools/lib
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 26992
diff changeset
    29
 * @modules jdk.compiler/com.sun.tools.javac.api
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 26992
diff changeset
    30
 *          jdk.compiler/com.sun.tools.javac.file
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 26992
diff changeset
    31
 *          jdk.compiler/com.sun.tools.javac.main
26992
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    32
 * @build Wrapper ToolBox
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    33
 * @run main Wrapper PackagePathMismatch
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    34
 */
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    35
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    36
import java.nio.file.Path;
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    37
import java.nio.file.Paths;
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    38
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    39
public class PackagePathMismatch extends SjavacBase {
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    40
    public static void main(String... args) throws Exception {
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    41
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    42
        Path root = Paths.get(PackagePathMismatch.class.getSimpleName() + "Test");
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    43
        Path src = root.resolve("src");
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    44
        Path classes = root.resolve("classes");
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    45
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    46
        toolbox.writeFile(src.resolve("a/x/c/Test.java"),
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    47
                          "package a.b.c; class Test { }");
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    48
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    49
        // Compile should fail since package a.b.c does not match path a/x/c.
33554
d29aff18b2f6 8141355: PackagePathMismatch.java does not use --state-dir option
alundblad
parents: 32337
diff changeset
    50
        int rc1 = compile("--server:portfile=testserver,background=false",
d29aff18b2f6 8141355: PackagePathMismatch.java does not use --state-dir option
alundblad
parents: 32337
diff changeset
    51
                          "-d", classes,
d29aff18b2f6 8141355: PackagePathMismatch.java does not use --state-dir option
alundblad
parents: 32337
diff changeset
    52
                          "--state-dir=" + classes,
d29aff18b2f6 8141355: PackagePathMismatch.java does not use --state-dir option
alundblad
parents: 32337
diff changeset
    53
                          src);
26992
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    54
        if (rc1 == 0)
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    55
            throw new AssertionError("Compilation succeeded unexpectedly");
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    56
    }
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff changeset
    57
}