author | jjg |
Mon, 13 Mar 2017 11:27:30 -0700 | |
changeset 44197 | 380e1f22e460 |
parent 43772 | 4e5350b7be75 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
44197 | 2 |
* Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. |
10 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
26 |
package javax.tools; |
|
27 |
||
28 |
import javax.tools.JavaFileManager.Location; |
|
29 |
||
30 |
import java.util.concurrent.*; |
|
31 |
||
32 |
/** |
|
33 |
* Standard locations of file objects. |
|
34 |
* |
|
35 |
* @author Peter von der Ahé |
|
36 |
* @since 1.6 |
|
37 |
*/ |
|
38 |
public enum StandardLocation implements Location { |
|
39 |
||
40 |
/** |
|
41 |
* Location of new class files. |
|
42 |
*/ |
|
43 |
CLASS_OUTPUT, |
|
44 |
||
45 |
/** |
|
46 |
* Location of new source files. |
|
47 |
*/ |
|
48 |
SOURCE_OUTPUT, |
|
49 |
||
50 |
/** |
|
51 |
* Location to search for user class files. |
|
52 |
*/ |
|
53 |
CLASS_PATH, |
|
54 |
||
55 |
/** |
|
56 |
* Location to search for existing source files. |
|
57 |
*/ |
|
58 |
SOURCE_PATH, |
|
59 |
||
60 |
/** |
|
61 |
* Location to search for annotation processors. |
|
62 |
*/ |
|
63 |
ANNOTATION_PROCESSOR_PATH, |
|
64 |
||
65 |
/** |
|
36526 | 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 | 68 |
* @since 9 |
69 |
*/ |
|
70 |
ANNOTATION_PROCESSOR_MODULE_PATH, |
|
71 |
||
72 |
/** |
|
10 | 73 |
* Location to search for platform classes. Sometimes called |
74 |
* the boot class path. |
|
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 | 82 |
NATIVE_HEADER_OUTPUT, |
83 |
||
84 |
/** |
|
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 | 87 |
* @since 9 |
88 |
*/ |
|
89 |
MODULE_SOURCE_PATH, |
|
90 |
||
91 |
/** |
|
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 | 94 |
* @since 9 |
95 |
*/ |
|
96 |
UPGRADE_MODULE_PATH, |
|
97 |
||
98 |
/** |
|
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 | 101 |
* @since 9 |
102 |
*/ |
|
103 |
SYSTEM_MODULES, |
|
104 |
||
105 |
/** |
|
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 | 108 |
* @since 9 |
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 | 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 | 118 |
|
119 |
/** |
|
25287 | 120 |
* Returns a location object with the given name. The following |
10 | 121 |
* property must hold: {@code locationFor(x) == |
122 |
* locationFor(y)} if and only if {@code x.equals(y)}. |
|
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 | 127 |
* |
128 |
* @param name a name |
|
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 | 133 |
*/ |
134 |
public static Location locationFor(final String name) { |
|
135 |
if (locations.isEmpty()) { |
|
136 |
// can't use valueOf which throws IllegalArgumentException |
|
137 |
for (Location location : values()) |
|
138 |
locations.putIfAbsent(location.getName(), location); |
|
139 |
} |
|
36526 | 140 |
name.getClass(); /* null-check */ |
141 |
locations.putIfAbsent(name, new Location() { |
|
142 |
@Override |
|
10 | 143 |
public String getName() { return name; } |
36526 | 144 |
@Override |
10 | 145 |
public boolean isOutputLocation() { return name.endsWith("_OUTPUT"); } |
146 |
}); |
|
147 |
return locations.get(name); |
|
148 |
} |
|
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 | 151 |
= new ConcurrentHashMap<>(); |
10 | 152 |
|
36526 | 153 |
@Override |
10 | 154 |
public String getName() { return name(); } |
155 |
||
36526 | 156 |
@Override |
10 | 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 | 166 |
} |
36526 | 167 |
|
44197 | 168 |
/** |
169 |
* {@inheritDoc} |
|
170 |
* @since 9 |
|
171 |
*/ |
|
36526 | 172 |
@Override |
42261
bb52b5514ad5
8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents:
36526
diff
changeset
|
173 |
public boolean isModuleOrientedLocation() { |
36526 | 174 |
switch (this) { |
175 |
case MODULE_SOURCE_PATH: |
|
176 |
case ANNOTATION_PROCESSOR_MODULE_PATH: |
|
177 |
case UPGRADE_MODULE_PATH: |
|
178 |
case SYSTEM_MODULES: |
|
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 | 181 |
return true; |
182 |
default: |
|
183 |
return false; |
|
184 |
} |
|
185 |
} |
|
10 | 186 |
} |