author | briangoetz |
Wed, 18 Dec 2013 16:05:18 -0500 | |
changeset 22163 | 3651128c74eb |
parent 14801 | d66cab4ef397 |
child 25287 | d2440361b323 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
12213
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
5520
diff
changeset
|
2 |
* Copyright (c) 2006, 2012, 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 |
/** |
|
66 |
* Location to search for platform classes. Sometimes called |
|
67 |
* the boot class path. |
|
68 |
*/ |
|
12213
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
5520
diff
changeset
|
69 |
PLATFORM_CLASS_PATH, |
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
5520
diff
changeset
|
70 |
|
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
5520
diff
changeset
|
71 |
/** |
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
5520
diff
changeset
|
72 |
* Location of new native header files. |
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
5520
diff
changeset
|
73 |
* @since 1.8 |
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
5520
diff
changeset
|
74 |
*/ |
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
5520
diff
changeset
|
75 |
NATIVE_HEADER_OUTPUT; |
10 | 76 |
|
77 |
/** |
|
78 |
* Gets a location object with the given name. The following |
|
79 |
* property must hold: {@code locationFor(x) == |
|
80 |
* locationFor(y)} if and only if {@code x.equals(y)}. |
|
81 |
* The returned location will be an output location if and only if |
|
82 |
* name ends with {@code "_OUTPUT"}. |
|
83 |
* |
|
84 |
* @param name a name |
|
85 |
* @return a location |
|
86 |
*/ |
|
87 |
public static Location locationFor(final String name) { |
|
88 |
if (locations.isEmpty()) { |
|
89 |
// can't use valueOf which throws IllegalArgumentException |
|
90 |
for (Location location : values()) |
|
91 |
locations.putIfAbsent(location.getName(), location); |
|
92 |
} |
|
93 |
locations.putIfAbsent(name.toString(/* null-check */), new Location() { |
|
94 |
public String getName() { return name; } |
|
95 |
public boolean isOutputLocation() { return name.endsWith("_OUTPUT"); } |
|
96 |
}); |
|
97 |
return locations.get(name); |
|
98 |
} |
|
99 |
//where |
|
14801
d66cab4ef397
8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents:
12213
diff
changeset
|
100 |
private static final ConcurrentMap<String,Location> locations |
22163 | 101 |
= new ConcurrentHashMap<>(); |
10 | 102 |
|
103 |
public String getName() { return name(); } |
|
104 |
||
105 |
public boolean isOutputLocation() { |
|
12213
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
5520
diff
changeset
|
106 |
switch (this) { |
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
5520
diff
changeset
|
107 |
case CLASS_OUTPUT: |
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
5520
diff
changeset
|
108 |
case SOURCE_OUTPUT: |
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
5520
diff
changeset
|
109 |
case NATIVE_HEADER_OUTPUT: |
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
5520
diff
changeset
|
110 |
return true; |
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
5520
diff
changeset
|
111 |
default: |
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
5520
diff
changeset
|
112 |
return false; |
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
5520
diff
changeset
|
113 |
} |
10 | 114 |
} |
115 |
} |