langtools/test/tools/javac/T6340549.java
author lana
Thu, 21 Jan 2016 09:46:01 -0800
changeset 35340 38f7386ed942
parent 30730 d3ce7619db2c
permissions -rw-r--r--
Added tag jdk-9+102 for changeset 7e3feb2ba5b3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6158
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
     1
/*
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 27319
diff changeset
     2
 * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
6158
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
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 27319
diff changeset
    27
 * @modules java.compiler
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 27319
diff changeset
    28
 *          jdk.compiler
6158
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    29
 */
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    30
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    31
import javax.tools.*;
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    32
import java.util.*;
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    33
import java.io.*;
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
import static javax.tools.JavaFileObject.Kind;
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    36
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    37
public class T6340549 {
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    38
    public static void main(String... args) throws Exception {
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    39
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    40
        // Ensure a directory exists
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    41
        File dir = new File("temp" + args.hashCode());
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    42
        if (!dir.exists())
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    43
            dir.mkdir();
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    44
        if (!dir.isDirectory())
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    45
            throw new AssertionError("Not a directory " + dir);
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    46
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    47
        try {
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    48
            JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
27319
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 6158
diff changeset
    49
            try (StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null)) {
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 6158
diff changeset
    50
                jfm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(new File(".")));
6158
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    51
27319
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 6158
diff changeset
    52
                for (JavaFileObject jfo : jfm.list(StandardLocation.CLASS_PATH,
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 6158
diff changeset
    53
                        "", EnumSet.of(Kind.OTHER), false)) {
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 6158
diff changeset
    54
                    if (new File(jfo.getName()).isDirectory()) {
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 6158
diff changeset
    55
                        throw new AssertionError("Found directory: " + jfo);
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 6158
diff changeset
    56
                    }
6158
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    57
                }
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
        } finally {
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    60
            dir.delete(); // cleanup
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    61
        }
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    62
    }
d02e088255a0 6340549: javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
jjg
parents:
diff changeset
    63
}