src/java.compiler/share/classes/javax/tools/StandardLocation.java
author naoto
Fri, 16 Feb 2018 14:03:34 -0800
changeset 48910 67cdc215ed70
parent 47216 71c04702a3d5
permissions -rw-r--r--
8198228: Spec clarification: j.u.Locale.getDisplayName() Reviewed-by: rriggs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
44197
380e1f22e460 8176492: @since value errors in java.compiler module
jjg
parents: 43772
diff changeset
     2
 * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1264
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1264
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1264
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1264
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1264
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package javax.tools;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import javax.tools.JavaFileManager.Location;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.util.concurrent.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * Standard locations of file objects.
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * @author Peter von der Ahé
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * @since 1.6
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
public enum StandardLocation implements Location {
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
     * Location of new class files.
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
    CLASS_OUTPUT,
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
     * Location of new source files.
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    SOURCE_OUTPUT,
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
     * Location to search for user class files.
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    CLASS_PATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     * Location to search for existing source files.
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    SOURCE_PATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     * Location to search for annotation processors.
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    ANNOTATION_PROCESSOR_PATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    /**
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    66
     * Location to search for modules containing annotation processors.
43767
9cff98a149cb 8173393: Module system implementation refresh (2/2017)
alanb
parents: 42261
diff changeset
    67
     * @spec JPMS
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    68
     * @since 9
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    69
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    70
    ANNOTATION_PROCESSOR_MODULE_PATH,
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    71
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    72
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     * Location to search for platform classes.  Sometimes called
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     * the boot class path.
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     */
12213
516b112d6c68 7150368: javac should include basic ability to generate native headers
jjg
parents: 5520
diff changeset
    76
    PLATFORM_CLASS_PATH,
516b112d6c68 7150368: javac should include basic ability to generate native headers
jjg
parents: 5520
diff changeset
    77
516b112d6c68 7150368: javac should include basic ability to generate native headers
jjg
parents: 5520
diff changeset
    78
    /**
516b112d6c68 7150368: javac should include basic ability to generate native headers
jjg
parents: 5520
diff changeset
    79
     * Location of new native header files.
516b112d6c68 7150368: javac should include basic ability to generate native headers
jjg
parents: 5520
diff changeset
    80
     * @since 1.8
516b112d6c68 7150368: javac should include basic ability to generate native headers
jjg
parents: 5520
diff changeset
    81
     */
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    82
    NATIVE_HEADER_OUTPUT,
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    83
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    84
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    85
     * Location to search for the source code of modules.
43767
9cff98a149cb 8173393: Module system implementation refresh (2/2017)
alanb
parents: 42261
diff changeset
    86
     * @spec JPMS
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    87
     * @since 9
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    88
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    89
    MODULE_SOURCE_PATH,
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    90
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    91
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    92
     * Location to search for upgradeable system modules.
43767
9cff98a149cb 8173393: Module system implementation refresh (2/2017)
alanb
parents: 42261
diff changeset
    93
     * @spec JPMS
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    94
     * @since 9
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    95
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    96
    UPGRADE_MODULE_PATH,
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    97
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    98
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    99
     * Location to search for system modules.
43767
9cff98a149cb 8173393: Module system implementation refresh (2/2017)
alanb
parents: 42261
diff changeset
   100
     * @spec JPMS
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   101
     * @since 9
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   102
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   103
    SYSTEM_MODULES,
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   104
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   105
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   106
     * Location to search for precompiled user modules.
43767
9cff98a149cb 8173393: Module system implementation refresh (2/2017)
alanb
parents: 42261
diff changeset
   107
     * @spec JPMS
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   108
     * @since 9
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   109
     */
43772
4e5350b7be75 8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents: 43767
diff changeset
   110
    MODULE_PATH,
4e5350b7be75 8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents: 43767
diff changeset
   111
4e5350b7be75 8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents: 43767
diff changeset
   112
    /**
4e5350b7be75 8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents: 43767
diff changeset
   113
     * Location to search for module patches.
44197
380e1f22e460 8176492: @since value errors in java.compiler module
jjg
parents: 43772
diff changeset
   114
     * @spec JPMS
43772
4e5350b7be75 8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents: 43767
diff changeset
   115
     * @since 9
4e5350b7be75 8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents: 43767
diff changeset
   116
     */
4e5350b7be75 8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents: 43767
diff changeset
   117
    PATCH_MODULE_PATH;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   120
     * Returns a location object with the given name.  The following
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     * property must hold: {@code locationFor(x) ==
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     * locationFor(y)} if and only if {@code x.equals(y)}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     * The returned location will be an output location if and only if
42261
bb52b5514ad5 8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents: 36526
diff changeset
   124
     * name ends with {@code "_OUTPUT"}. It will be considered to
bb52b5514ad5 8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents: 36526
diff changeset
   125
     * be a module-oriented location if the name contains the word
bb52b5514ad5 8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents: 36526
diff changeset
   126
     * {@code "MODULE"}.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     * @param name a name
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     * @return a location
43767
9cff98a149cb 8173393: Module system implementation refresh (2/2017)
alanb
parents: 42261
diff changeset
   130
     *
9cff98a149cb 8173393: Module system implementation refresh (2/2017)
alanb
parents: 42261
diff changeset
   131
     * @revised 9
9cff98a149cb 8173393: Module system implementation refresh (2/2017)
alanb
parents: 42261
diff changeset
   132
     * @spec JPMS
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
    public static Location locationFor(final String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
        if (locations.isEmpty()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
            // can't use valueOf which throws IllegalArgumentException
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
            for (Location location : values())
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
                locations.putIfAbsent(location.getName(), location);
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
        }
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   140
        name.getClass(); /* null-check */
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   141
        locations.putIfAbsent(name, new Location() {
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   142
                @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
                public String getName() { return name; }
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   144
                @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
                public boolean isOutputLocation() { return name.endsWith("_OUTPUT"); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
            });
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
        return locations.get(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
    //where
14801
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 12213
diff changeset
   150
        private static final ConcurrentMap<String,Location> locations
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 14801
diff changeset
   151
            = new ConcurrentHashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   153
    @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
    public String getName() { return name(); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   156
    @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
    public boolean isOutputLocation() {
12213
516b112d6c68 7150368: javac should include basic ability to generate native headers
jjg
parents: 5520
diff changeset
   158
        switch (this) {
516b112d6c68 7150368: javac should include basic ability to generate native headers
jjg
parents: 5520
diff changeset
   159
            case CLASS_OUTPUT:
516b112d6c68 7150368: javac should include basic ability to generate native headers
jjg
parents: 5520
diff changeset
   160
            case SOURCE_OUTPUT:
516b112d6c68 7150368: javac should include basic ability to generate native headers
jjg
parents: 5520
diff changeset
   161
            case NATIVE_HEADER_OUTPUT:
516b112d6c68 7150368: javac should include basic ability to generate native headers
jjg
parents: 5520
diff changeset
   162
                return true;
516b112d6c68 7150368: javac should include basic ability to generate native headers
jjg
parents: 5520
diff changeset
   163
            default:
516b112d6c68 7150368: javac should include basic ability to generate native headers
jjg
parents: 5520
diff changeset
   164
                return false;
516b112d6c68 7150368: javac should include basic ability to generate native headers
jjg
parents: 5520
diff changeset
   165
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    }
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   167
44197
380e1f22e460 8176492: @since value errors in java.compiler module
jjg
parents: 43772
diff changeset
   168
    /**
380e1f22e460 8176492: @since value errors in java.compiler module
jjg
parents: 43772
diff changeset
   169
     * {@inheritDoc}
380e1f22e460 8176492: @since value errors in java.compiler module
jjg
parents: 43772
diff changeset
   170
     * @since 9
380e1f22e460 8176492: @since value errors in java.compiler module
jjg
parents: 43772
diff changeset
   171
     */
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   172
    @Override
42261
bb52b5514ad5 8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents: 36526
diff changeset
   173
    public boolean isModuleOrientedLocation() {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   174
        switch (this) {
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   175
            case MODULE_SOURCE_PATH:
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   176
            case ANNOTATION_PROCESSOR_MODULE_PATH:
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   177
            case UPGRADE_MODULE_PATH:
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   178
            case SYSTEM_MODULES:
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   179
            case MODULE_PATH:
43772
4e5350b7be75 8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents: 43767
diff changeset
   180
            case PATCH_MODULE_PATH:
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   181
                return true;
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   182
            default:
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   183
                return false;
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   184
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   185
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
}