author | wetmore |
Tue, 26 Aug 2014 17:09:05 -0700 | |
changeset 28543 | 31afdc0e77af |
parent 26992 | 92e69fa21956 |
child 30730 | d3ce7619db2c |
permissions | -rw-r--r-- |
26992
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
1 |
/* |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
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 |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
31 |
* @build Wrapper ToolBox |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
32 |
* @run main Wrapper PackagePathMismatch |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
33 |
*/ |
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 |
import java.nio.file.Path; |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
36 |
import java.nio.file.Paths; |
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 |
public class PackagePathMismatch extends SjavacBase { |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
39 |
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
|
40 |
|
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
41 |
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
|
42 |
Path src = root.resolve("src"); |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
43 |
Path classes = root.resolve("classes"); |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
44 |
|
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
45 |
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
|
46 |
"package a.b.c; class Test { }"); |
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 |
// 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
|
49 |
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
|
50 |
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
|
51 |
if (rc1 == 0) |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
52 |
throw new AssertionError("Compilation succeeded unexpectedly"); |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
53 |
} |
92e69fa21956
8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents:
diff
changeset
|
54 |
} |