langtools/test/tools/javac/api/TestSearchPaths.java
author avstepan
Tue, 19 May 2015 16:04:14 +0400
changeset 30655 d83f50188ca9
parent 27579 d1a63c99cdd5
child 30730 d3ce7619db2c
permissions -rw-r--r--
8080422: some docs cleanup for core libs Summary: some docs cleanup Reviewed-by: rriggs, lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
     1
/*
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
     4
 *
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
     8
 *
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    13
 * accompanied this code).
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    14
 *
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    18
 *
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    21
 * questions.
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    22
 */
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    23
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    24
/*
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    25
 * @test
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    26
 * @bug 7026941
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    27
 * @summary path options ignored when reusing filemanager across tasks
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    28
 */
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    29
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    30
import java.io.File;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    31
import java.io.FileWriter;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    32
import java.io.IOException;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    33
import java.io.PrintWriter;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    34
import java.net.URI;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    35
import java.nio.file.Files;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    36
import java.util.ArrayList;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    37
import java.util.Arrays;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    38
import java.util.Collections;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    39
import java.util.EnumSet;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    40
import java.util.List;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    41
import java.util.Objects;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    42
import java.util.jar.JarEntry;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    43
import java.util.jar.JarOutputStream;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    44
import java.util.regex.Matcher;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    45
import java.util.regex.Pattern;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    46
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    47
import javax.tools.JavaCompiler;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    48
import javax.tools.JavaCompiler.CompilationTask;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    49
import javax.tools.JavaFileObject;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    50
import javax.tools.SimpleJavaFileObject;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    51
import javax.tools.StandardJavaFileManager;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    52
import javax.tools.StandardLocation;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    53
import javax.tools.ToolProvider;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    54
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    55
import static javax.tools.StandardLocation.*;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    56
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    57
/**
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    58
 * Test for combinations of using javac command-line options and fileManager setLocation
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    59
 * calls to affect the locations available in the fileManager.
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    60
 *
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    61
 * Using a single Java compiler and file manager, for each of the standard locations,
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    62
 * a series of operations is performed, using either compiler options or setLocation
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    63
 * calls. Each operation includes a compilation, and then a check for the value of
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    64
 * the standard location available in the file manager.
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    65
 *
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    66
 * The operations generate and use unique files to minimize the possibility of false
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    67
 * positive results.
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    68
 */
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    69
public class TestSearchPaths {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    70
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    71
    public static void main(String... args) throws Exception {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    72
        TestSearchPaths t = new TestSearchPaths();
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    73
        t.run();
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    74
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    75
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    76
    void run() throws Exception {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    77
        compiler = ToolProvider.getSystemJavaCompiler();
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    78
        fileManager = compiler.getStandardFileManager(null, null, null);
27319
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
    79
        try {
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
    80
            // basic output path
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
    81
            testClassOutput();
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    82
27319
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
    83
            // basic search paths
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
    84
            testClassPath();
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
    85
            testSourcePath();
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
    86
            testPlatformClassPath();
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
    87
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
    88
            // annotation processing
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
    89
            testAnnotationProcessorPath();
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
    90
            testSourceOutput();
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    91
27319
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
    92
            // javah equivalent
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
    93
            testNativeHeaderOutput();
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
    94
27319
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
    95
            // future-proof: guard against new StandardLocations being added
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
    96
            if (!tested.equals(EnumSet.allOf(StandardLocation.class))) {
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
    97
                error("not all standard locations have been tested");
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
    98
                out.println("not yet tested: " + EnumSet.complementOf(tested));
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
    99
            }
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   100
27319
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
   101
            if (errors > 0) {
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
   102
                throw new Exception(errors + " errors occurred");
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
   103
            }
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
   104
        } finally {
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 24897
diff changeset
   105
            fileManager.close();
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   106
        }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   107
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   108
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   109
    void testClassOutput() throws IOException {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   110
        String test = "testClassOutput";
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 27319
diff changeset
   111
        System.err.println("test: " + test);
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   112
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   113
        for (int i = 1; i <= 5; i++) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   114
            File classes = createDir(test + "/" + i + "/classes");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   115
            List<String> options;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   116
            switch (i) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   117
                default:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   118
                    options = getOptions("-d", classes.getPath());
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   119
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   120
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   121
                case 3:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   122
                    setLocation(CLASS_OUTPUT, classes);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   123
                    options = null;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   124
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   125
            }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   126
            List<JavaFileObject> sources = getSources("class C" + i + " { }");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   127
            callTask(options, sources);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   128
            checkPath(CLASS_OUTPUT, Mode.EQUALS, classes);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   129
            checkFile(CLASS_OUTPUT, "C" + i + ".class");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   130
        }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   131
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   132
        tested.add(CLASS_OUTPUT);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   133
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   134
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   135
    void testClassPath() throws IOException {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   136
        String test = "testClassPath";
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 27319
diff changeset
   137
        System.err.println("test: " + test);
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   138
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   139
        for (int i = 1; i <= 5; i++) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   140
            File classes = createDir(test + "/" + i + "/classes");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   141
            File classpath = new File("testClassOutput/" + i + "/classes");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   142
            List<String> options;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   143
            switch (i) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   144
                default:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   145
                    options = getOptions("-d", classes.getPath(), "-classpath", classpath.getPath());
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   146
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   147
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   148
                case 3:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   149
                    setLocation(CLASS_PATH, classpath);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   150
                    options = getOptions("-d", classes.getPath());
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   151
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   152
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   153
                case 4:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   154
                    options = getOptions("-d", classes.getPath(), "-cp", classpath.getPath());
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   155
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   156
            }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   157
            List<JavaFileObject> sources = getSources("class D" + i + " { C" + i + " c; }");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   158
            callTask(options, sources);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   159
            checkPath(CLASS_PATH, Mode.EQUALS, classpath);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   160
            checkFile(CLASS_OUTPUT, "D" + i + ".class");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   161
        }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   162
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   163
        tested.add(CLASS_PATH);
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 27319
diff changeset
   164
        System.err.println();
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   165
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   166
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   167
    void testSourcePath() throws IOException {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   168
        String test = "testSourcePath";
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 27319
diff changeset
   169
        System.err.println("test: " + test);
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   170
        setLocation(CLASS_PATH); // empty
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   171
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   172
        for (int i = 1; i <= 5; i++) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   173
            File src = createDir(test + "/" + i + "/src");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   174
            writeFile(src, "C" + i + ".java", "class C" + i + "{ }");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   175
            File classes = createDir(test + "/" + i + "/classes");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   176
            File srcpath = src;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   177
            List<String> options;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   178
            switch (i) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   179
                default:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   180
                    options = getOptions("-d", classes.getPath(), "-sourcepath", srcpath.getPath());
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   181
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   182
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   183
                case 3:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   184
                    setLocation(SOURCE_PATH, srcpath);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   185
                    options = getOptions("-d", classes.getPath());
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   186
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   187
            }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   188
            List<JavaFileObject> sources = getSources("class D" + i + " { C" + i + " c; }");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   189
            callTask(options, sources);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   190
            checkPath(SOURCE_PATH, Mode.EQUALS, srcpath);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   191
            checkFile(CLASS_OUTPUT, "D" + i + ".class");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   192
        }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   193
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   194
        tested.add(SOURCE_PATH);
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 27319
diff changeset
   195
        System.err.println();
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   196
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   197
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   198
    void testPlatformClassPath() throws IOException {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   199
        String test = "testPlatformClassPath";
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 27319
diff changeset
   200
        System.err.println("test: " + test);
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   201
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   202
        List<File> defaultPath = getLocation(PLATFORM_CLASS_PATH);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   203
        StringBuilder sb = new StringBuilder();
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   204
        for (File f: defaultPath) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   205
            if (sb.length() > 0)
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   206
                sb.append(File.pathSeparator);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   207
            sb.append(f);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   208
        }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   209
        String defaultPathString = sb.toString();
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   210
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   211
        setLocation(CLASS_PATH); // empty
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   212
        setLocation(SOURCE_PATH); // empty
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   213
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 27319
diff changeset
   214
        // FIXME: temporarily exclude cases referring to default bootclasspath
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 27319
diff changeset
   215
        // for (int i = 1; i <= 10; i++) {
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 27319
diff changeset
   216
        int[] cases = new int[] { 1, 2, 4, 5, 6, 7 };
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 27319
diff changeset
   217
        for (int i : cases) {
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   218
            File classes = createDir(test + "/" + i + "/classes");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   219
            File testJars = createDir(test + "/" + i + "/testJars");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   220
            File testClasses = createDir(test + "/" + i + "/testClasses");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   221
            callTask(getOptions("-d", testClasses.getPath()), getSources("class C" + i + " { }"));
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   222
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   223
            List<String> options;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   224
            Mode mode;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   225
            List<File> match;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   226
            String reference = "C" + i + " c;";
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   227
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   228
            File jar;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   229
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   230
            switch (i) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   231
                case 1:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   232
                    options = getOptions("-d", classes.getPath(), "-Xbootclasspath/p:" + testClasses);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   233
                    mode = Mode.STARTS_WITH;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   234
                    match = Arrays.asList(testClasses);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   235
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   236
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   237
                case 2:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   238
                    // the default values for -extdirs and -endorseddirs come after the bootclasspath;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   239
                    // so to check -Xbootclasspath/a: we specify empty values for those options.
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   240
                    options = getOptions("-d", classes.getPath(),
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   241
                            "-Xbootclasspath/a:" + testClasses,
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   242
                            "-extdirs", "",
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   243
                            "-endorseddirs", "");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   244
                    mode = Mode.ENDS_WITH;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   245
                    match = Arrays.asList(testClasses);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   246
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   247
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   248
                case 3:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   249
                    options = getOptions("-d", classes.getPath(), "-Xbootclasspath:" + defaultPathString);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   250
                    mode = Mode.EQUALS;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   251
                    match = defaultPath;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   252
                    reference = "";
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   253
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   254
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   255
                case 4:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   256
                    fileManager.setLocation(PLATFORM_CLASS_PATH, null);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   257
                    jar = new File(testJars, "j" + i + ".jar");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   258
                    writeJar(jar, testClasses, "C" + i + ".class");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   259
                    options = getOptions("-d", classes.getPath(), "-endorseddirs", testJars.getPath());
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   260
                    mode = Mode.CONTAINS;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   261
                    match = Arrays.asList(jar);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   262
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   263
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   264
                case 5:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   265
                    fileManager.setLocation(PLATFORM_CLASS_PATH, null);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   266
                    jar = new File(testJars, "j" + i + ".jar");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   267
                    writeJar(jar, testClasses, "C" + i + ".class");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   268
                    options = getOptions("-d", classes.getPath(), "-Djava.endorsed.dirs=" + testJars.getPath());
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   269
                    mode = Mode.CONTAINS;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   270
                    match = Arrays.asList(jar);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   271
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   272
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   273
                case 6:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   274
                    fileManager.setLocation(PLATFORM_CLASS_PATH, null);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   275
                    jar = new File(testJars, "j" + i + ".jar");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   276
                    writeJar(jar, testClasses, "C" + i + ".class");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   277
                    options = getOptions("-d", classes.getPath(), "-extdirs", testJars.getPath());
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   278
                    mode = Mode.CONTAINS;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   279
                    match = Arrays.asList(jar);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   280
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   281
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   282
                case 7:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   283
                    fileManager.setLocation(PLATFORM_CLASS_PATH, null);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   284
                    jar = new File(testJars, "j" + i + ".jar");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   285
                    writeJar(jar, testClasses, "C" + i + ".class");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   286
                    options = getOptions("-d", classes.getPath(), "-Djava.ext.dirs=" + testJars.getPath());
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   287
                    mode = Mode.CONTAINS;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   288
                    match = Arrays.asList(jar);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   289
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   290
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   291
                case 8:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   292
                    setLocation(PLATFORM_CLASS_PATH, defaultPath);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   293
                    options = getOptions("-d", classes.getPath());
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   294
                    mode = Mode.EQUALS;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   295
                    match = defaultPath;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   296
                    reference = "";
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   297
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   298
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   299
                default:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   300
                    options = getOptions("-d", classes.getPath(), "-bootclasspath", defaultPathString);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   301
                    mode = Mode.EQUALS;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   302
                    match = defaultPath;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   303
                    reference = "";
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   304
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   305
            }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   306
            List<JavaFileObject> sources = getSources("class D" + i + " { " + reference + " }");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   307
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   308
            callTask(options, sources);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   309
            checkPath(PLATFORM_CLASS_PATH, mode, match);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   310
            checkFile(CLASS_OUTPUT, "D" + i + ".class");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   311
        }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   312
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   313
        tested.add(PLATFORM_CLASS_PATH);
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 27319
diff changeset
   314
        System.err.println();
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   315
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   316
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   317
    void testAnnotationProcessorPath() throws IOException {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   318
        String test = "testAnnotationProcessorPath";
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 27319
diff changeset
   319
        System.err.println("test: " + test);
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 27319
diff changeset
   320
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 27319
diff changeset
   321
        fileManager.setLocation(PLATFORM_CLASS_PATH, null);
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   322
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   323
        String template =
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   324
                "import java.util.*;\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   325
                + "import javax.annotation.processing.*;\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   326
                + "import javax.lang.model.*;\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   327
                + "import javax.lang.model.element.*;\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   328
                + "@SupportedAnnotationTypes(\"*\")\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   329
                + "public class A%d extends AbstractProcessor {\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   330
                + "    public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) {\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   331
                + "        return true;\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   332
                + "    }\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   333
                + "    public SourceVersion getSupportedSourceVersion() {\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   334
                + "        return SourceVersion.latest();\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   335
                + "    }\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   336
                + "}";
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   337
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   338
        for (int i = 1; i <= 5; i++) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   339
            File classes = createDir(test + "/" + i + "/classes");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   340
            File annodir = createDir(test + "/" + i + "/processors");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   341
            callTask(getOptions("-d", annodir.getPath()), getSources(String.format(template, i)));
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   342
            File annopath = annodir;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   343
            List<String> options;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   344
            switch (i) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   345
                default:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   346
                    options = getOptions("-d", classes.getPath(),
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   347
                            "-processorpath", annopath.getPath(),
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   348
                            "-processor", "A" + i);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   349
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   350
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   351
                case 3:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   352
                    setLocation(ANNOTATION_PROCESSOR_PATH, annopath);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   353
                    options = getOptions("-d", classes.getPath(),
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   354
                            "-processor", "A" + i);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   355
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   356
            }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   357
            List<JavaFileObject> sources = getSources("class D" + i + " { }");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   358
            callTask(options, sources);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   359
            checkPath(ANNOTATION_PROCESSOR_PATH, Mode.EQUALS, annopath);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   360
            checkFile(CLASS_OUTPUT, "D" + i + ".class");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   361
        }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   362
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   363
        tested.add(ANNOTATION_PROCESSOR_PATH);
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 27319
diff changeset
   364
        System.err.println();
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   365
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   366
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   367
    void testSourceOutput() throws IOException {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   368
        String test = "testAnnotationProcessorPath";
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 27319
diff changeset
   369
        System.err.println("test: " + test);
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   370
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   371
        String source =
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   372
                "import java.io.*;\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   373
                + "import java.util.*;\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   374
                + "import javax.annotation.processing.*;\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   375
                + "import javax.lang.model.*;\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   376
                + "import javax.lang.model.element.*;\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   377
                + "import javax.tools.*;\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   378
                + "@SupportedOptions(\"name\")\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   379
                + "@SupportedAnnotationTypes(\"*\")\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   380
                + "public class A extends AbstractProcessor {\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   381
                + "    int round = 0;\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   382
                + "    public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) {\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   383
                + "        if (round++ == 0) try {\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   384
                + "            String name = processingEnv.getOptions().get(\"name\");\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   385
                + "            JavaFileObject fo = processingEnv.getFiler().createSourceFile(name);\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   386
                + "            try (Writer out = fo.openWriter()) {\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   387
                + "                out.write(\"class \" + name + \" { }\");\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   388
                + "            }\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   389
                + "        } catch (IOException e) { throw new Error(e); }\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   390
                + "        return true;\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   391
                + "    }\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   392
                + "    public SourceVersion getSupportedSourceVersion() {\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   393
                + "        return SourceVersion.latest();\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   394
                + "    }\n"
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   395
                + "}";
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   396
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   397
        File annodir = createDir(test + "/processors");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   398
        callTask(getOptions("-d", annodir.getPath()), getSources(source));
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   399
        setLocation(ANNOTATION_PROCESSOR_PATH, annodir);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   400
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   401
        for (int i = 1; i <= 5; i++) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   402
            File classes = createDir(test + "/" + i + "/classes");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   403
            File genSrc = createDir(test + "/" + "/genSrc");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   404
            List<String> options;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   405
            switch (i) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   406
                default:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   407
                    options = getOptions("-d", classes.getPath(),
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   408
                            "-processor", "A", "-Aname=G" + i,
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   409
                            "-s", genSrc.getPath());
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   410
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   411
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   412
                case 3:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   413
                    setLocation(SOURCE_OUTPUT, genSrc);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   414
                    options = getOptions("-d", classes.getPath(),
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   415
                            "-processor", "A", "-Aname=G" + i);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   416
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   417
            }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   418
            List<JavaFileObject> sources = getSources("class D" + i + " { }");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   419
            callTask(options, sources);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   420
            checkPath(SOURCE_OUTPUT, Mode.EQUALS, genSrc);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   421
            checkFile(CLASS_OUTPUT, "D" + i + ".class");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   422
            checkFile(CLASS_OUTPUT, "G" + i + ".class");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   423
        }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   424
        tested.add(SOURCE_OUTPUT);
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 27319
diff changeset
   425
        System.err.println();
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   426
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   427
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   428
    void testNativeHeaderOutput() throws IOException {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   429
        String test = "testNativeHeaderOutput";
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 27319
diff changeset
   430
        System.err.println("test: " + test);
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   431
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   432
        for (int i = 1; i <= 5; i++) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   433
            File classes = createDir(test + "/" + i + "/classes");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   434
            File headers = createDir(test + "/" + i + "/hdrs");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   435
            List<String> options;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   436
            switch (i) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   437
                default:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   438
                    options = getOptions("-d", classes.getPath(), "-h", headers.getPath());
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   439
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   440
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   441
                case 3:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   442
                    setLocation(NATIVE_HEADER_OUTPUT, headers);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   443
                    options = getOptions("-d", classes.getPath());
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   444
                    break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   445
            }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   446
            List<JavaFileObject> sources = getSources("class C" + i + " { native void m(); }");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   447
            callTask(options, sources);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   448
            checkPath(NATIVE_HEADER_OUTPUT, Mode.EQUALS, headers);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   449
            checkFile(NATIVE_HEADER_OUTPUT, "C" + i + ".h");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   450
        }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   451
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   452
        tested.add(StandardLocation.NATIVE_HEADER_OUTPUT);
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 27319
diff changeset
   453
        System.err.println();
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   454
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   455
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   456
    List<String> getOptions(String... args) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   457
        return Arrays.asList(args);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   458
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   459
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   460
    List<JavaFileObject> getSources(String... sources) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   461
        List<JavaFileObject> list = new ArrayList<>();
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   462
        for (String s: sources)
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   463
            list.add(getSource(s));
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   464
        return list;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   465
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   466
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   467
    JavaFileObject getSource(final String source) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   468
        return new SimpleJavaFileObject(getURIFromSource(source), JavaFileObject.Kind.SOURCE) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   469
            @Override
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   470
            public CharSequence getCharContent(boolean ignoreEncodingErrors) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   471
                return source;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   472
            }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   473
        };
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   474
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   475
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   476
    void callTask(List<String> options, List<JavaFileObject> files) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   477
        out.print("compile: ");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   478
        if (options != null) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   479
            for (String o: options) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   480
                if (o.length() > 64) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   481
                    o = o.substring(0, 32) + "..." + o.substring(o.length() - 32);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   482
                }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   483
                out.print(" " + o);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   484
            }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   485
        }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   486
        for (JavaFileObject f: files)
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   487
            out.print(" " + f.getName());
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   488
        out.println();
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   489
        CompilationTask t = compiler.getTask(out, fileManager, null, options, null, files);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   490
        boolean ok = t.call();
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   491
        if (!ok)
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   492
            error("compilation failed");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   493
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   494
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   495
    enum Mode { EQUALS, CONTAINS, STARTS_WITH, ENDS_WITH };
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   496
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   497
    void checkFile(StandardLocation l, String path) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   498
        if (!l.isOutputLocation()) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   499
            error("Not an output location: " + l);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   500
            return;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   501
        }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   502
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   503
        List<File> files = getLocation(l);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   504
        if (files == null) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   505
            error("location is unset: " + l);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   506
            return;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   507
        }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   508
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   509
        if (files.size() != 1)
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   510
            error("unexpected number of entries on " + l + ": " + files.size());
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   511
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   512
        File f = new File(files.get(0), path);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   513
        if (!f.exists())
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   514
            error("file not found: " + f);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   515
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   516
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   517
    void checkPath(StandardLocation l, Mode m, File expect) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   518
        checkPath(l, m, Arrays.asList(expect));
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   519
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   520
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   521
    void checkPath(StandardLocation l, Mode m, List<File> expect) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   522
        List<File> files = getLocation(l);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   523
        if (files == null) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   524
            error("location is unset: " + l);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   525
            return;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   526
        }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   527
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   528
        switch (m) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   529
            case EQUALS:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   530
                if (!Objects.equals(files, expect)) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   531
                    error("location does not match the expected files: " + l);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   532
                    out.println("found:  " + files);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   533
                    out.println("expect: " + expect);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   534
                }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   535
                break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   536
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   537
            case CONTAINS:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   538
                int containsIndex = Collections.indexOfSubList(files, expect);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   539
                if (containsIndex == -1) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   540
                    error("location does not contain the expected files: " + l);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   541
                    out.println("found:  " + files);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   542
                    out.println("expect: " + expect);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   543
                }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   544
            break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   545
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   546
            case STARTS_WITH:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   547
                int startsIndex = Collections.indexOfSubList(files, expect);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   548
                if (startsIndex != 0) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   549
                    error("location does not start with the expected files: " + l);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   550
                    out.println("found:  " + files);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   551
                    out.println("expect: " + expect);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   552
                }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   553
            break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   554
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   555
            case ENDS_WITH:
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   556
                int endsIndex = Collections.lastIndexOfSubList(files, expect);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   557
                if (endsIndex != files.size() - expect.size()) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   558
                    error("location does not end with the expected files: " + l);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   559
                    out.println("found:  " + files);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   560
                    out.println("expect: " + expect);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   561
                }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   562
            break;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   563
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   564
        }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   565
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   566
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   567
    List<File> getLocation(StandardLocation l) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   568
        Iterable<? extends File> iter = fileManager.getLocation(l);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   569
        if (iter == null)
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   570
            return null;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   571
        List<File> files = new ArrayList<>();
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   572
        for (File f: iter)
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   573
            files.add(f);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   574
        return files;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   575
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   576
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   577
    void setLocation(StandardLocation l, File... files) throws IOException {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   578
        fileManager.setLocation(l, Arrays.asList(files));
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   579
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   580
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   581
    void setLocation(StandardLocation l, List<File> files) throws IOException {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   582
        fileManager.setLocation(l, files);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   583
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   584
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   585
    void writeFile(File dir, String path, String body) throws IOException {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   586
        try (FileWriter w = new FileWriter(new File(dir, path))) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   587
            w.write(body);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   588
        }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   589
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   590
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   591
    void writeJar(File jar, File dir, String... entries) throws IOException {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   592
        try (JarOutputStream j = new JarOutputStream(Files.newOutputStream(jar.toPath()))) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   593
            for (String entry: entries) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   594
                j.putNextEntry(new JarEntry(entry));
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   595
                j.write(Files.readAllBytes(dir.toPath().resolve(entry)));
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   596
            }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   597
        }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   598
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   599
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   600
    private static final Pattern packagePattern
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   601
            = Pattern.compile("package\\s+(((?:\\w+\\.)*)(?:\\w+))");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   602
    private static final Pattern classPattern
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   603
            = Pattern.compile("(?:public\\s+)?(?:class|enum|interface)\\s+(\\w+)");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   604
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   605
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   606
    private static URI getURIFromSource(String source) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   607
        String packageName = null;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   608
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   609
        Matcher matcher = packagePattern.matcher(source);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   610
        if (matcher.find()) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   611
            packageName = matcher.group(1).replace(".", "/");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   612
        }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   613
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   614
        matcher = classPattern.matcher(source);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   615
        if (matcher.find()) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   616
            String className = matcher.group(1);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   617
            String path = ((packageName == null) ? "" : packageName + "/") + className + ".java";
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   618
            return URI.create("myfo:///" + path);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   619
        } else {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   620
            throw new Error("Could not extract the java class "
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   621
                    + "name from the provided source");
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   622
        }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   623
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   624
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   625
    File createDir(String path) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   626
        File dir = new File(path);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   627
        dir.mkdirs();
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   628
        return dir;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   629
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   630
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   631
    JavaCompiler compiler;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   632
    StandardJavaFileManager fileManager;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   633
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   634
    /**
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   635
     * Map for recording which standard locations have been tested.
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   636
     */
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   637
    EnumSet<StandardLocation> tested = EnumSet.noneOf(StandardLocation.class);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   638
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   639
    /**
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   640
     * Logging stream. Used directly with test and for getTask calls.
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   641
     */
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   642
    final PrintWriter out = new PrintWriter(System.err, true);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   643
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   644
    /**
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   645
     * Count of errors so far.
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   646
     */
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   647
    int errors;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   648
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   649
    void error(String message) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   650
        errors++;
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   651
        out.println("Error: " + message);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   652
    }
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
diff changeset
   653
}