src/jdk.compiler/share/classes/com/sun/tools/javac/main/DelegatingJavaFileManager.java
author jlahoda
Mon, 06 Nov 2017 13:10:43 +0100
changeset 47702 cf8310446245
child 54298 6207397a6603
permissions -rw-r--r--
8139607: -release option forces StandardJavaFileManager Summary: Merging a --release specific file manager with the user-provided one, rather than altering the user-provided one. Reviewed-by: jjg, mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47702
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
     1
/*
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
     4
 *
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    10
 *
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    15
 * accompanied this code).
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    16
 *
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    20
 *
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    23
 * questions.
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    24
 */
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    25
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    26
package com.sun.tools.javac.main;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    27
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    28
import java.io.File;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    29
import java.io.IOException;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    30
import java.nio.file.Path;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    31
import java.util.Collection;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    32
import java.util.Iterator;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    33
import java.util.ServiceLoader;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    34
import java.util.Set;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    35
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    36
import javax.tools.FileObject;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    37
import javax.tools.JavaFileManager;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    38
import javax.tools.JavaFileManager.Location;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    39
import javax.tools.JavaFileObject;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    40
import javax.tools.JavaFileObject.Kind;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    41
import javax.tools.StandardJavaFileManager;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    42
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    43
import com.sun.tools.javac.util.Context;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    44
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    45
/**
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    46
 * A JavaFileManager that delegates to one of two delegate ClassLoaders.
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    47
 */
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    48
public class DelegatingJavaFileManager implements JavaFileManager {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    49
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    50
    public static void installReleaseFileManager(Context context,
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    51
                                                 JavaFileManager releaseFM,
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    52
                                                 JavaFileManager originalFM) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    53
        context.put(JavaFileManager.class, (JavaFileManager) null);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    54
        JavaFileManager nue = originalFM instanceof StandardJavaFileManager
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    55
                ? new DelegatingSJFM(releaseFM,
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    56
                                                        (StandardJavaFileManager) originalFM)
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    57
                : new DelegatingJavaFileManager(releaseFM, originalFM);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    58
        context.put(JavaFileManager.class, nue);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    59
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    60
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    61
    private final JavaFileManager releaseFM;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    62
    private final JavaFileManager baseFM;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    63
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    64
    private DelegatingJavaFileManager(JavaFileManager releaseFM, JavaFileManager baseFM) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    65
        this.releaseFM = releaseFM;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    66
        this.baseFM = baseFM;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    67
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    68
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    69
    private JavaFileManager delegate(Location location) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    70
        if (releaseFM.hasLocation(location)) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    71
            return releaseFM;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    72
        }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    73
        return baseFM;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    74
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    75
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    76
    @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    77
    public ClassLoader getClassLoader(Location location) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    78
        return delegate(location).getClassLoader(location);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    79
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    80
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    81
    @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    82
    public Iterable<JavaFileObject> list(Location location, String packageName,
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    83
                                         Set<Kind> kinds, boolean recurse) throws IOException {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    84
        return delegate(location).list(location, packageName, kinds, recurse);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    85
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    86
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    87
    @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    88
    public String inferBinaryName(Location location, JavaFileObject file) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    89
        return delegate(location).inferBinaryName(location, file);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    90
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    91
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    92
    @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    93
    public boolean isSameFile(FileObject a, FileObject b) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    94
        return baseFM.isSameFile(a, b);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    95
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    96
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    97
    @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    98
    public boolean handleOption(String current, Iterator<String> remaining) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
    99
        return baseFM.handleOption(current, remaining);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   100
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   101
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   102
    @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   103
    public boolean hasLocation(Location location) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   104
        return releaseFM.hasLocation(location) || baseFM.hasLocation(location);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   105
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   106
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   107
    @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   108
    public JavaFileObject getJavaFileForInput(Location location, String className,
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   109
                                              Kind kind) throws IOException {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   110
        return delegate(location).getJavaFileForInput(location, className, kind);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   111
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   112
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   113
    @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   114
    public JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind,
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   115
                                               FileObject sibling) throws IOException {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   116
        return delegate(location).getJavaFileForOutput(location, className, kind, sibling);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   117
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   118
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   119
    @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   120
    public FileObject getFileForInput(Location location, String packageName,
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   121
                                      String relativeName) throws IOException {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   122
        return delegate(location).getFileForInput(location, packageName, relativeName);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   123
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   124
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   125
    @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   126
    public FileObject getFileForOutput(Location location, String packageName, String relativeName,
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   127
                                       FileObject sibling) throws IOException {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   128
        return delegate(location).getFileForOutput(location, packageName, relativeName, sibling);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   129
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   130
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   131
    @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   132
    public void flush() throws IOException {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   133
        releaseFM.flush();
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   134
        baseFM.flush();
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   135
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   136
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   137
    @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   138
    public void close() throws IOException {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   139
        releaseFM.close();
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   140
        baseFM.close();
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   141
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   142
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   143
    @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   144
    public Location getLocationForModule(Location location,
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   145
                                         String moduleName) throws IOException {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   146
        return delegate(location).getLocationForModule(location, moduleName);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   147
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   148
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   149
    @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   150
    public Location getLocationForModule(Location location,
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   151
                                         JavaFileObject fo) throws IOException {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   152
        return delegate(location).getLocationForModule(location, fo);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   153
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   154
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   155
    @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   156
    public <S> ServiceLoader<S> getServiceLoader(Location location,
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   157
                                                 Class<S> service) throws IOException {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   158
        return delegate(location).getServiceLoader(location, service);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   159
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   160
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   161
    @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   162
    public String inferModuleName(Location location) throws IOException {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   163
        return delegate(location).inferModuleName(location);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   164
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   165
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   166
    @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   167
    public Iterable<Set<Location>> listLocationsForModules(Location location) throws IOException {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   168
        return delegate(location).listLocationsForModules(location);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   169
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   170
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   171
    @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   172
    public boolean contains(Location location, FileObject fo) throws IOException {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   173
        return delegate(location).contains(location, fo);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   174
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   175
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   176
    @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   177
    public int isSupportedOption(String option) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   178
        return baseFM.isSupportedOption(option);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   179
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   180
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   181
    public JavaFileManager getBaseFileManager() {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   182
        return baseFM;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   183
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   184
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   185
    private static final class DelegatingSJFM extends DelegatingJavaFileManager
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   186
                                              implements StandardJavaFileManager {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   187
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   188
        private final StandardJavaFileManager baseSJFM;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   189
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   190
        private DelegatingSJFM(JavaFileManager releaseFM,
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   191
                                                  StandardJavaFileManager baseSJFM) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   192
            super(releaseFM, baseSJFM);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   193
            this.baseSJFM = baseSJFM;
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   194
        }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   195
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   196
        @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   197
        public boolean isSameFile(FileObject a, FileObject b) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   198
            return baseSJFM.isSameFile(a, b);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   199
        }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   200
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   201
        @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   202
        public Iterable<? extends JavaFileObject> getJavaFileObjectsFromFiles
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   203
                                                  (Iterable<? extends File> files) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   204
            return baseSJFM.getJavaFileObjectsFromFiles(files);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   205
        }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   206
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   207
        @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   208
        public Iterable<? extends JavaFileObject> getJavaFileObjectsFromPaths
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   209
                                                  (Iterable<? extends Path> paths) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   210
            return baseSJFM.getJavaFileObjectsFromPaths(paths);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   211
        }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   212
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   213
        @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   214
        public Iterable<? extends JavaFileObject> getJavaFileObjects(File... files) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   215
            return baseSJFM.getJavaFileObjects(files);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   216
        }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   217
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   218
        @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   219
        public Iterable<? extends JavaFileObject> getJavaFileObjects(Path... paths) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   220
            return baseSJFM.getJavaFileObjects(paths);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   221
        }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   222
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   223
        @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   224
        public Iterable<? extends JavaFileObject> getJavaFileObjectsFromStrings
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   225
                                                  (Iterable<String> names) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   226
            return baseSJFM.getJavaFileObjectsFromStrings(names);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   227
        }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   228
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   229
        @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   230
        public Iterable<? extends JavaFileObject> getJavaFileObjects(String... names) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   231
            return baseSJFM.getJavaFileObjects(names);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   232
        }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   233
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   234
        @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   235
        public void setLocation(Location location,
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   236
                                Iterable<? extends File> files) throws IOException {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   237
            baseSJFM.setLocation(location, files);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   238
        }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   239
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   240
        @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   241
        public void setLocationFromPaths(Location location,
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   242
                                         Collection<? extends Path> paths) throws IOException {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   243
            baseSJFM.setLocationFromPaths(location, paths);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   244
        }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   245
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   246
        @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   247
        public void setLocationForModule(Location location, String moduleName,
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   248
                                         Collection<? extends Path> paths) throws IOException {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   249
            baseSJFM.setLocationForModule(location, moduleName, paths);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   250
        }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   251
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   252
        @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   253
        public Iterable<? extends File> getLocation(Location location) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   254
            return baseSJFM.getLocation(location);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   255
        }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   256
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   257
        @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   258
        public Iterable<? extends Path> getLocationAsPaths(Location location) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   259
            return baseSJFM.getLocationAsPaths(location);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   260
        }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   261
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   262
        @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   263
        public Path asPath(FileObject file) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   264
            return baseSJFM.asPath(file);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   265
        }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   266
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   267
        @Override
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   268
        public void setPathFactory(PathFactory f) {
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   269
            baseSJFM.setPathFactory(f);
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   270
        }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   271
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   272
    }
cf8310446245 8139607: -release option forces StandardJavaFileManager
jlahoda
parents:
diff changeset
   273
}