author | jjg |
Thu, 26 May 2016 10:45:13 -0700 | |
changeset 38611 | b5a479aff686 |
parent 37758 | 3ecf9b414e05 |
permissions | -rw-r--r-- |
36526 | 1 |
/* |
2 |
* Copyright (c) 2016, 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. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/** |
|
25 |
* @test |
|
26 |
* @bug 8149033 |
|
27 |
* @summary ClassCastException in case of service implementation is nested static class |
|
28 |
* @library /tools/lib |
|
29 |
* @modules |
|
30 |
* jdk.compiler/com.sun.tools.javac.api |
|
31 |
* jdk.compiler/com.sun.tools.javac.main |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
32 |
* @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase |
36526 | 33 |
* @run main ServiceInStaticClassErrorTest |
34 |
*/ |
|
35 |
||
36 |
import java.nio.file.Files; |
|
37 |
import java.nio.file.Path; |
|
38 |
import java.util.List; |
|
39 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
40 |
import toolbox.JavacTask; |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
41 |
import toolbox.Task; |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
42 |
import toolbox.ToolBox; |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
43 |
|
36526 | 44 |
public class ServiceInStaticClassErrorTest extends ModuleTestBase { |
45 |
public static void main(String... args) throws Exception { |
|
46 |
ServiceInStaticClassErrorTest t = new ServiceInStaticClassErrorTest(); |
|
47 |
t.runTests(); |
|
48 |
} |
|
49 |
||
50 |
@Test |
|
37758 | 51 |
public void testError(Path base) throws Exception { |
36526 | 52 |
Path src = base.resolve("src"); |
53 |
tb.writeJavaFiles(src, |
|
54 |
"module m { provides p1.I with p1.Outer.A; }", |
|
55 |
"package p1; public interface I {}", |
|
56 |
"package p1; public class Outer { public static class A implements p1.I {} }"); |
|
57 |
Path classes = base.resolve("classes"); |
|
58 |
Files.createDirectories(classes); |
|
59 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
60 |
List<String> output = new JavacTask(tb) |
36526 | 61 |
.outdir(classes) |
62 |
.files(findJavaFiles(src)) |
|
63 |
.run() |
|
64 |
.writeAll() |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
65 |
.getOutputLines(Task.OutputKind.DIRECT); |
36526 | 66 |
} |
67 |
||
68 |
} |