author | akulyakh |
Thu, 21 May 2015 11:41:04 -0700 | |
changeset 30730 | d3ce7619db2c |
parent 26992 | 92e69fa21956 |
child 32337 | c9d3ab9f601c |
permissions | -rw-r--r-- |
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 |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
10 |
* |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
11 |
* 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
|
12 |
* 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
|
13 |
* 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
|
14 |
* 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
|
15 |
* accompanied this code). |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
16 |
* |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
17 |
* 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
|
18 |
* 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
|
19 |
* 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
|
20 |
* |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
21 |
* 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
|
22 |
* 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
|
23 |
* questions. |
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 |
|
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
26 |
/* |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
27 |
* @test |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
28 |
* @bug 8059349 |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
29 |
* @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
|
30 |
* @library /tools/lib |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26992
diff
changeset
|
31 |
* @modules jdk.compiler/com.sun.tools.javac.api |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26992
diff
changeset
|
32 |
* jdk.compiler/com.sun.tools.javac.file |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26992
diff
changeset
|
33 |
* 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
|
34 |
* @build Wrapper ToolBox |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
35 |
* @run main Wrapper PackagePathMismatch |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
36 |
*/ |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
37 |
|
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
38 |
import java.nio.file.Path; |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
39 |
import java.nio.file.Paths; |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
40 |
|
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
41 |
public class PackagePathMismatch extends SjavacBase { |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
42 |
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
|
43 |
|
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
44 |
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
|
45 |
Path src = root.resolve("src"); |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
46 |
Path classes = root.resolve("classes"); |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
47 |
|
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
48 |
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
|
49 |
"package a.b.c; class Test { }"); |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
50 |
|
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
51 |
// Compile should fail since package a.b.c does not match path a/x/c. |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
52 |
String server = "--server:portfile=testserver,background=false"; |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
53 |
int rc1 = compile(server, "-d", classes, src); |
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 |
} |