author | katleman |
Thu, 21 Aug 2014 14:16:14 -0700 | |
changeset 25878 | 6d561031123e |
parent 6158 | d02e088255a0 |
child 27319 | 030080f03e4f |
permissions | -rw-r--r-- |
6158
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
1 |
/* |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
2 |
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
4 |
* |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
8 |
* |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
13 |
* accompanied this code). |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
14 |
* |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
18 |
* |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
21 |
* questions. |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
22 |
*/ |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
23 |
|
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
24 |
/* |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
25 |
* @test 6403456 |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
26 |
* @summary javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
27 |
*/ |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
28 |
|
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
29 |
import javax.tools.*; |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
30 |
import java.util.*; |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
31 |
import java.io.*; |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
32 |
|
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
33 |
import static javax.tools.JavaFileObject.Kind; |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
34 |
|
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
35 |
public class T6340549 { |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
36 |
public static void main(String... args) throws Exception { |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
37 |
|
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
38 |
// Ensure a directory exists |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
39 |
File dir = new File("temp" + args.hashCode()); |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
40 |
if (!dir.exists()) |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
41 |
dir.mkdir(); |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
42 |
if (!dir.isDirectory()) |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
43 |
throw new AssertionError("Not a directory " + dir); |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
44 |
|
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
45 |
try { |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
46 |
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
47 |
StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null); |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
48 |
jfm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(new File("."))); |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
49 |
|
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
50 |
for (JavaFileObject jfo : jfm.list(StandardLocation.CLASS_PATH, |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
51 |
"", EnumSet.of(Kind.OTHER), false)) { |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
52 |
if (new File(jfo.getName()).isDirectory()) { |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
53 |
throw new AssertionError("Found directory: " + jfo); |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
54 |
} |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
55 |
} |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
56 |
} finally { |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
57 |
dir.delete(); // cleanup |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
58 |
} |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
59 |
} |
d02e088255a0
6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff
changeset
|
60 |
} |