author | jjh |
Tue, 25 Oct 2011 19:18:32 -0700 | |
changeset 10819 | e1a8df45d8b0 |
parent 10818 | e95eb04c68cc |
child 11314 | b612aaca08d0 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
8034
d3b29ef9c062
6430241: Hard to disable symbol file feature through API
jjg
parents:
7847
diff
changeset
|
2 |
* Copyright (c) 2003, 2011, 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 |
||
731
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
171
diff
changeset
|
26 |
package com.sun.tools.javac.file; |
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
171
diff
changeset
|
27 |
|
10818 | 28 |
import java.io.FileNotFoundException; |
29 |
import java.util.Iterator; |
|
10 | 30 |
import java.io.File; |
31 |
import java.io.IOException; |
|
4937
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
32 |
import java.net.MalformedURLException; |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
33 |
import java.net.URL; |
10818 | 34 |
import java.util.Arrays; |
35 |
import java.util.Collection; |
|
36 |
import java.util.Collections; |
|
37 |
import java.util.EnumMap; |
|
38 |
import java.util.EnumSet; |
|
10 | 39 |
import java.util.HashMap; |
40 |
import java.util.HashSet; |
|
10818 | 41 |
import java.util.LinkedHashSet; |
10 | 42 |
import java.util.Map; |
43 |
import java.util.Set; |
|
4937
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
44 |
import java.util.StringTokenizer; |
10 | 45 |
import java.util.zip.ZipFile; |
46 |
import javax.tools.JavaFileManager.Location; |
|
10818 | 47 |
import javax.tools.StandardLocation; |
10 | 48 |
|
731
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
171
diff
changeset
|
49 |
import com.sun.tools.javac.code.Lint; |
10818 | 50 |
import com.sun.tools.javac.main.OptionName; |
1486 | 51 |
import com.sun.tools.javac.util.ListBuffer; |
731
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
171
diff
changeset
|
52 |
import com.sun.tools.javac.util.Log; |
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
171
diff
changeset
|
53 |
import com.sun.tools.javac.util.Options; |
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
171
diff
changeset
|
54 |
|
10818 | 55 |
import javax.tools.JavaFileManager; |
731
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
171
diff
changeset
|
56 |
import static javax.tools.StandardLocation.*; |
10 | 57 |
import static com.sun.tools.javac.main.OptionName.*; |
58 |
||
59 |
/** This class converts command line arguments, environment variables |
|
60 |
* and system properties (in File.pathSeparator-separated String form) |
|
61 |
* into a boot class path, user class path, and source path (in |
|
62 |
* Collection<String> form). |
|
63 |
* |
|
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
64 |
* <p><b>This is NOT part of any supported API. |
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
65 |
* If you write code that depends on this, you do so at your own risk. |
10 | 66 |
* This code and its internal interfaces are subject to change or |
67 |
* deletion without notice.</b> |
|
68 |
*/ |
|
10818 | 69 |
public class Locations { |
10 | 70 |
|
71 |
/** The log to use for warning output */ |
|
72 |
private Log log; |
|
73 |
||
74 |
/** Collection of command-line options */ |
|
75 |
private Options options; |
|
76 |
||
77 |
/** Handler for -Xlint options */ |
|
78 |
private Lint lint; |
|
79 |
||
1208 | 80 |
/** Access to (possibly cached) file info */ |
81 |
private FSInfo fsInfo; |
|
10 | 82 |
|
10818 | 83 |
/** Whether to warn about non-existent path elements */ |
84 |
private boolean warn; |
|
85 |
||
86 |
// TODO: remove need for this |
|
87 |
private boolean inited = false; // TODO? caching bad? |
|
88 |
||
89 |
public Locations() { |
|
90 |
initHandlers(); |
|
10 | 91 |
} |
92 |
||
10813
95b39a692cd0
7101146: Paths should more directly managed by BaseFileManager
jjg
parents:
8424
diff
changeset
|
93 |
public void update(Log log, Options options, Lint lint, FSInfo fsInfo) { |
95b39a692cd0
7101146: Paths should more directly managed by BaseFileManager
jjg
parents:
8424
diff
changeset
|
94 |
this.log = log; |
95b39a692cd0
7101146: Paths should more directly managed by BaseFileManager
jjg
parents:
8424
diff
changeset
|
95 |
this.options = options; |
95b39a692cd0
7101146: Paths should more directly managed by BaseFileManager
jjg
parents:
8424
diff
changeset
|
96 |
this.lint = lint; |
95b39a692cd0
7101146: Paths should more directly managed by BaseFileManager
jjg
parents:
8424
diff
changeset
|
97 |
this.fsInfo = fsInfo; |
10 | 98 |
} |
99 |
||
10818 | 100 |
public Collection<File> bootClassPath() { |
101 |
return getLocation(PLATFORM_CLASS_PATH); |
|
10 | 102 |
} |
103 |
||
7336
3fd30668e9b5
7003477: Paths.isDefaultBootClassPath needs to be public
jjg
parents:
7335
diff
changeset
|
104 |
public boolean isDefaultBootClassPath() { |
10818 | 105 |
BootClassPathLocationHandler h = |
106 |
(BootClassPathLocationHandler) getHandler(PLATFORM_CLASS_PATH); |
|
107 |
return h.isDefault(); |
|
10 | 108 |
} |
109 |
||
8034
d3b29ef9c062
6430241: Hard to disable symbol file feature through API
jjg
parents:
7847
diff
changeset
|
110 |
boolean isDefaultBootClassPathRtJar(File file) { |
10818 | 111 |
BootClassPathLocationHandler h = |
112 |
(BootClassPathLocationHandler) getHandler(PLATFORM_CLASS_PATH); |
|
113 |
return h.isDefaultRtJar(file); |
|
114 |
} |
|
115 |
||
116 |
public Collection<File> userClassPath() { |
|
117 |
return getLocation(CLASS_PATH); |
|
118 |
} |
|
119 |
||
120 |
public Collection<File> sourcePath() { |
|
121 |
Collection<File> p = getLocation(SOURCE_PATH); |
|
122 |
// TODO: this should be handled by the LocationHandler |
|
123 |
return p == null || p.isEmpty() ? null : p; |
|
10 | 124 |
} |
125 |
||
1486 | 126 |
/** |
127 |
* Split a path into its elements. Empty path elements will be ignored. |
|
128 |
* @param path The path to be split |
|
129 |
* @return The elements of the path |
|
130 |
*/ |
|
131 |
private static Iterable<File> getPathEntries(String path) { |
|
132 |
return getPathEntries(path, null); |
|
133 |
} |
|
10 | 134 |
|
1486 | 135 |
/** |
136 |
* Split a path into its elements. If emptyPathDefault is not null, all |
|
137 |
* empty elements in the path, including empty elements at either end of |
|
138 |
* the path, will be replaced with the value of emptyPathDefault. |
|
139 |
* @param path The path to be split |
|
140 |
* @param emptyPathDefault The value to substitute for empty path elements, |
|
141 |
* or null, to ignore empty path elements |
|
142 |
* @return The elements of the path |
|
143 |
*/ |
|
144 |
private static Iterable<File> getPathEntries(String path, File emptyPathDefault) { |
|
145 |
ListBuffer<File> entries = new ListBuffer<File>(); |
|
146 |
int start = 0; |
|
147 |
while (start <= path.length()) { |
|
148 |
int sep = path.indexOf(File.pathSeparatorChar, start); |
|
149 |
if (sep == -1) |
|
150 |
sep = path.length(); |
|
151 |
if (start < sep) |
|
152 |
entries.add(new File(path.substring(start, sep))); |
|
153 |
else if (emptyPathDefault != null) |
|
154 |
entries.add(emptyPathDefault); |
|
155 |
start = sep + 1; |
|
10 | 156 |
} |
1486 | 157 |
return entries; |
10 | 158 |
} |
159 |
||
10818 | 160 |
/** |
161 |
* Utility class to help evaluate a path option. |
|
162 |
* Duplicate entries are ignored, jar class paths can be expanded. |
|
163 |
*/ |
|
10 | 164 |
private class Path extends LinkedHashSet<File> { |
165 |
private static final long serialVersionUID = 0; |
|
166 |
||
167 |
private boolean expandJarClassPaths = false; |
|
168 |
private Set<File> canonicalValues = new HashSet<File>(); |
|
169 |
||
170 |
public Path expandJarClassPaths(boolean x) { |
|
171 |
expandJarClassPaths = x; |
|
172 |
return this; |
|
173 |
} |
|
174 |
||
175 |
/** What to use when path element is the empty string */ |
|
1486 | 176 |
private File emptyPathDefault = null; |
10 | 177 |
|
1486 | 178 |
public Path emptyPathDefault(File x) { |
10 | 179 |
emptyPathDefault = x; |
180 |
return this; |
|
181 |
} |
|
182 |
||
183 |
public Path() { super(); } |
|
184 |
||
185 |
public Path addDirectories(String dirs, boolean warn) { |
|
8424
5e31b2eb5aa3
6485027: javac incorrectly handles relative paths in manifest classpath
jjg
parents:
8034
diff
changeset
|
186 |
boolean prev = expandJarClassPaths; |
5e31b2eb5aa3
6485027: javac incorrectly handles relative paths in manifest classpath
jjg
parents:
8034
diff
changeset
|
187 |
expandJarClassPaths = true; |
5e31b2eb5aa3
6485027: javac incorrectly handles relative paths in manifest classpath
jjg
parents:
8034
diff
changeset
|
188 |
try { |
5e31b2eb5aa3
6485027: javac incorrectly handles relative paths in manifest classpath
jjg
parents:
8034
diff
changeset
|
189 |
if (dirs != null) |
5e31b2eb5aa3
6485027: javac incorrectly handles relative paths in manifest classpath
jjg
parents:
8034
diff
changeset
|
190 |
for (File dir : getPathEntries(dirs)) |
5e31b2eb5aa3
6485027: javac incorrectly handles relative paths in manifest classpath
jjg
parents:
8034
diff
changeset
|
191 |
addDirectory(dir, warn); |
5e31b2eb5aa3
6485027: javac incorrectly handles relative paths in manifest classpath
jjg
parents:
8034
diff
changeset
|
192 |
return this; |
5e31b2eb5aa3
6485027: javac incorrectly handles relative paths in manifest classpath
jjg
parents:
8034
diff
changeset
|
193 |
} finally { |
5e31b2eb5aa3
6485027: javac incorrectly handles relative paths in manifest classpath
jjg
parents:
8034
diff
changeset
|
194 |
expandJarClassPaths = prev; |
5e31b2eb5aa3
6485027: javac incorrectly handles relative paths in manifest classpath
jjg
parents:
8034
diff
changeset
|
195 |
} |
10 | 196 |
} |
197 |
||
198 |
public Path addDirectories(String dirs) { |
|
199 |
return addDirectories(dirs, warn); |
|
200 |
} |
|
201 |
||
1486 | 202 |
private void addDirectory(File dir, boolean warn) { |
203 |
if (!dir.isDirectory()) { |
|
10 | 204 |
if (warn) |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
205 |
log.warning(Lint.LintCategory.PATH, |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
206 |
"dir.path.element.not.found", dir); |
10 | 207 |
return; |
208 |
} |
|
209 |
||
1486 | 210 |
File[] files = dir.listFiles(); |
10 | 211 |
if (files == null) |
212 |
return; |
|
213 |
||
214 |
for (File direntry : files) { |
|
215 |
if (isArchive(direntry)) |
|
216 |
addFile(direntry, warn); |
|
217 |
} |
|
218 |
} |
|
219 |
||
220 |
public Path addFiles(String files, boolean warn) { |
|
7335
8b390fd27190
6900037: javac should warn if earlier -source is used and bootclasspath not set
jjg
parents:
6151
diff
changeset
|
221 |
if (files != null) { |
10818 | 222 |
addFiles(getPathEntries(files, emptyPathDefault), warn); |
223 |
} |
|
224 |
return this; |
|
225 |
} |
|
226 |
||
227 |
public Path addFiles(String files) { |
|
228 |
return addFiles(files, warn); |
|
229 |
} |
|
230 |
||
231 |
public Path addFiles(Iterable<? extends File> files, boolean warn) { |
|
232 |
if (files != null) { |
|
233 |
for (File file: files) |
|
10 | 234 |
addFile(file, warn); |
7335
8b390fd27190
6900037: javac should warn if earlier -source is used and bootclasspath not set
jjg
parents:
6151
diff
changeset
|
235 |
} |
10 | 236 |
return this; |
237 |
} |
|
238 |
||
10818 | 239 |
public Path addFiles(Iterable<? extends File> files) { |
10 | 240 |
return addFiles(files, warn); |
241 |
} |
|
242 |
||
243 |
public void addFile(File file, boolean warn) { |
|
7839
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
244 |
if (contains(file)) { |
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
245 |
// discard duplicates |
10 | 246 |
return; |
247 |
} |
|
248 |
||
1208 | 249 |
if (! fsInfo.exists(file)) { |
10 | 250 |
/* No such file or directory exists */ |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
251 |
if (warn) { |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
252 |
log.warning(Lint.LintCategory.PATH, |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
253 |
"path.element.not.found", file); |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
254 |
} |
7839
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
255 |
super.add(file); |
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
256 |
return; |
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
257 |
} |
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
258 |
|
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
259 |
File canonFile = fsInfo.getCanonicalFile(file); |
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
260 |
if (canonicalValues.contains(canonFile)) { |
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
261 |
/* Discard duplicates and avoid infinite recursion */ |
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
262 |
return; |
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
263 |
} |
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
264 |
|
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
265 |
if (fsInfo.isFile(file)) { |
10 | 266 |
/* File is an ordinary file. */ |
267 |
if (!isArchive(file)) { |
|
268 |
/* Not a recognized extension; open it to see if |
|
269 |
it looks like a valid zip file. */ |
|
270 |
try { |
|
271 |
ZipFile z = new ZipFile(file); |
|
272 |
z.close(); |
|
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
273 |
if (warn) { |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
274 |
log.warning(Lint.LintCategory.PATH, |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
275 |
"unexpected.archive.file", file); |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
276 |
} |
10 | 277 |
} catch (IOException e) { |
278 |
// FIXME: include e.getLocalizedMessage in warning |
|
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
279 |
if (warn) { |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
280 |
log.warning(Lint.LintCategory.PATH, |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
281 |
"invalid.archive.file", file); |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
282 |
} |
10 | 283 |
return; |
284 |
} |
|
285 |
} |
|
286 |
} |
|
287 |
||
288 |
/* Now what we have left is either a directory or a file name |
|
7839
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
289 |
conforming to archive naming convention */ |
10 | 290 |
super.add(file); |
1208 | 291 |
canonicalValues.add(canonFile); |
10 | 292 |
|
7839
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
293 |
if (expandJarClassPaths && fsInfo.isFile(file)) |
10 | 294 |
addJarClassPath(file, warn); |
295 |
} |
|
296 |
||
297 |
// Adds referenced classpath elements from a jar's Class-Path |
|
298 |
// Manifest entry. In some future release, we may want to |
|
299 |
// update this code to recognize URLs rather than simple |
|
300 |
// filenames, but if we do, we should redo all path-related code. |
|
301 |
private void addJarClassPath(File jarFile, boolean warn) { |
|
302 |
try { |
|
1208 | 303 |
for (File f: fsInfo.getJarClassPath(jarFile)) { |
304 |
addFile(f, warn); |
|
10 | 305 |
} |
306 |
} catch (IOException e) { |
|
5007
28dee2489196
6930076: "null" can incorrectly appear in error message compiler.err.error.reading.file
jjg
parents:
4937
diff
changeset
|
307 |
log.error("error.reading.file", jarFile, JavacFileManager.getMessage(e)); |
10 | 308 |
} |
309 |
} |
|
310 |
} |
|
311 |
||
10818 | 312 |
/** |
313 |
* Base class for handling support for the representation of Locations. |
|
314 |
* Implementations are responsible for handling the interactions between |
|
315 |
* the command line options for a location, and API access via setLocation. |
|
316 |
* @see #initHandlers |
|
317 |
* @see #getHandler |
|
318 |
*/ |
|
319 |
protected abstract class LocationHandler { |
|
320 |
final Location location; |
|
321 |
final Set<OptionName> options; |
|
7335
8b390fd27190
6900037: javac should warn if earlier -source is used and bootclasspath not set
jjg
parents:
6151
diff
changeset
|
322 |
|
10818 | 323 |
/** |
324 |
* Create a handler. The location and options provide a way to map |
|
325 |
* from a location or an option to the corresponding handler. |
|
326 |
* @see #initHandlers |
|
327 |
*/ |
|
328 |
protected LocationHandler(Location location, OptionName... options) { |
|
329 |
this.location = location; |
|
10819
e1a8df45d8b0
7104905: Java SE build fails on call to CreateSymbols
jjh
parents:
10818
diff
changeset
|
330 |
this.options = options.length == 0 ? |
e1a8df45d8b0
7104905: Java SE build fails on call to CreateSymbols
jjh
parents:
10818
diff
changeset
|
331 |
EnumSet.noneOf(OptionName.class): |
e1a8df45d8b0
7104905: Java SE build fails on call to CreateSymbols
jjh
parents:
10818
diff
changeset
|
332 |
EnumSet.copyOf(Arrays.asList(options)); |
10818 | 333 |
} |
10 | 334 |
|
10818 | 335 |
// TODO: TEMPORARY, while Options still used for command line options |
336 |
void update(Options optionTable) { |
|
337 |
for (OptionName o: options) { |
|
338 |
String v = optionTable.get(o); |
|
339 |
if (v != null) { |
|
340 |
handleOption(o, v); |
|
341 |
} |
|
10 | 342 |
} |
343 |
} |
|
344 |
||
10818 | 345 |
/** @see JavaFileManager#handleOption. */ |
346 |
abstract boolean handleOption(OptionName option, String value); |
|
347 |
/** @see JavaFileManager#getLocation. */ |
|
348 |
abstract Collection<File> getLocation(); |
|
349 |
/** @see JavaFileManager#setLocation. */ |
|
350 |
abstract void setLocation(Iterable<? extends File> files) throws IOException; |
|
351 |
} |
|
352 |
||
353 |
/** |
|
354 |
* General purpose implementation for output locations, |
|
355 |
* such as -d/CLASS_OUTPUT and -s/SOURCE_OUTPUT. |
|
356 |
* All options are treated as equivalent (i.e. aliases.) |
|
357 |
* The value is a single file, possibly null. |
|
358 |
*/ |
|
359 |
private class OutputLocationHandler extends LocationHandler { |
|
360 |
private File outputDir; |
|
361 |
||
362 |
OutputLocationHandler(Location location, OptionName... options) { |
|
363 |
super(location, options); |
|
364 |
} |
|
365 |
||
366 |
@Override |
|
367 |
boolean handleOption(OptionName option, String value) { |
|
368 |
if (!options.contains(option)) |
|
369 |
return false; |
|
10 | 370 |
|
10818 | 371 |
// TODO: could/should validate outputDir exists and is a directory |
372 |
// need to decide how best to report issue for benefit of |
|
373 |
// direct API call on JavaFileManager.handleOption(specifies IAE) |
|
374 |
// vs. command line decoding. |
|
375 |
outputDir = new File(value); |
|
376 |
return true; |
|
377 |
} |
|
378 |
||
379 |
@Override |
|
380 |
Collection<File> getLocation() { |
|
381 |
return (outputDir == null) ? null : Collections.singleton(outputDir); |
|
382 |
} |
|
10 | 383 |
|
10818 | 384 |
@Override |
385 |
void setLocation(Iterable<? extends File> files) throws IOException { |
|
386 |
if (files == null) { |
|
387 |
outputDir = null; |
|
388 |
} else { |
|
389 |
Iterator<? extends File> pathIter = files.iterator(); |
|
390 |
if (!pathIter.hasNext()) |
|
391 |
throw new IllegalArgumentException("empty path for directory"); |
|
392 |
File dir = pathIter.next(); |
|
393 |
if (pathIter.hasNext()) |
|
394 |
throw new IllegalArgumentException("path too long for directory"); |
|
395 |
if (!dir.exists()) |
|
396 |
throw new FileNotFoundException(dir + ": does not exist"); |
|
397 |
else if (!dir.isDirectory()) |
|
398 |
throw new IOException(dir + ": not a directory"); |
|
399 |
outputDir = dir; |
|
400 |
} |
|
401 |
} |
|
10 | 402 |
} |
403 |
||
10818 | 404 |
/** |
405 |
* General purpose implementation for search path locations, |
|
406 |
* such as -sourcepath/SOURCE_PATH and -processorPath/ANNOTATION_PROCESS_PATH. |
|
407 |
* All options are treated as equivalent (i.e. aliases.) |
|
408 |
* The value is an ordered set of files and/or directories. |
|
409 |
*/ |
|
410 |
private class SimpleLocationHandler extends LocationHandler { |
|
411 |
protected Collection<File> searchPath; |
|
10 | 412 |
|
10818 | 413 |
SimpleLocationHandler(Location location, OptionName... options) { |
414 |
super(location, options); |
|
415 |
} |
|
10 | 416 |
|
10818 | 417 |
@Override |
418 |
boolean handleOption(OptionName option, String value) { |
|
419 |
if (!options.contains(option)) |
|
420 |
return false; |
|
421 |
searchPath = value == null ? null : |
|
422 |
Collections.unmodifiableCollection(computePath(value)); |
|
423 |
return true; |
|
424 |
} |
|
425 |
||
426 |
protected Path computePath(String value) { |
|
427 |
return new Path().addFiles(value); |
|
428 |
} |
|
10 | 429 |
|
10818 | 430 |
@Override |
431 |
Collection<File> getLocation() { |
|
432 |
return searchPath; |
|
433 |
} |
|
10 | 434 |
|
10818 | 435 |
@Override |
436 |
void setLocation(Iterable<? extends File> files) { |
|
437 |
Path p; |
|
438 |
if (files == null) { |
|
439 |
p = computePath(null); |
|
440 |
} else { |
|
441 |
p = new Path().addFiles(files); |
|
442 |
} |
|
443 |
searchPath = Collections.unmodifiableCollection(p); |
|
444 |
} |
|
10 | 445 |
} |
446 |
||
10818 | 447 |
/** |
448 |
* Subtype of SimpleLocationHandler for -classpath/CLASS_PATH. |
|
449 |
* If no value is given, a default is provided, based on system properties |
|
450 |
* and other values. |
|
451 |
*/ |
|
452 |
private class ClassPathLocationHandler extends SimpleLocationHandler { |
|
453 |
ClassPathLocationHandler() { |
|
454 |
super(StandardLocation.CLASS_PATH, |
|
455 |
OptionName.CLASSPATH, OptionName.CP); |
|
456 |
} |
|
457 |
||
458 |
@Override |
|
459 |
Collection<File> getLocation() { |
|
460 |
lazy(); |
|
461 |
return searchPath; |
|
462 |
} |
|
463 |
||
464 |
@Override |
|
465 |
protected Path computePath(String value) { |
|
466 |
String cp = value; |
|
10 | 467 |
|
10818 | 468 |
// CLASSPATH environment variable when run from `javac'. |
469 |
if (cp == null) cp = System.getProperty("env.class.path"); |
|
470 |
||
471 |
// If invoked via a java VM (not the javac launcher), use the |
|
472 |
// platform class path |
|
473 |
if (cp == null && System.getProperty("application.home") == null) |
|
474 |
cp = System.getProperty("java.class.path"); |
|
475 |
||
476 |
// Default to current working directory. |
|
477 |
if (cp == null) cp = "."; |
|
478 |
||
479 |
return new Path() |
|
480 |
.expandJarClassPaths(true) // Only search user jars for Class-Paths |
|
481 |
.emptyPathDefault(new File(".")) // Empty path elt ==> current directory |
|
482 |
.addFiles(cp); |
|
483 |
} |
|
484 |
||
485 |
private void lazy() { |
|
486 |
if (searchPath == null) |
|
487 |
setLocation(null); |
|
488 |
} |
|
10 | 489 |
} |
490 |
||
10818 | 491 |
/** |
492 |
* Custom subtype of LocationHandler for PLATFORM_CLASS_PATH. |
|
493 |
* Various options are supported for different components of the |
|
494 |
* platform class path. |
|
495 |
* Setting a value with setLocation overrides all existing option values. |
|
496 |
* Setting any option overrides any value set with setLocation, and reverts |
|
497 |
* to using default values for options that have not been set. |
|
498 |
* Setting -bootclasspath or -Xbootclasspath overrides any existing |
|
499 |
* value for -Xbootclasspath/p: and -Xbootclasspath/a:. |
|
500 |
*/ |
|
501 |
private class BootClassPathLocationHandler extends LocationHandler { |
|
502 |
private Collection<File> searchPath; |
|
503 |
final Map<OptionName, String> optionValues = new EnumMap<OptionName,String>(OptionName.class); |
|
504 |
||
505 |
/** |
|
506 |
* rt.jar as found on the default bootclasspath. |
|
507 |
* If the user specified a bootclasspath, null is used. |
|
508 |
*/ |
|
509 |
private File defaultBootClassPathRtJar = null; |
|
10 | 510 |
|
10818 | 511 |
/** |
512 |
* Is bootclasspath the default? |
|
513 |
*/ |
|
514 |
private boolean isDefaultBootClassPath; |
|
515 |
||
516 |
BootClassPathLocationHandler() { |
|
517 |
super(StandardLocation.PLATFORM_CLASS_PATH, |
|
518 |
OptionName.BOOTCLASSPATH, OptionName.XBOOTCLASSPATH, |
|
519 |
OptionName.XBOOTCLASSPATH_PREPEND, |
|
520 |
OptionName.XBOOTCLASSPATH_APPEND, |
|
521 |
OptionName.ENDORSEDDIRS, OptionName.DJAVA_ENDORSED_DIRS, |
|
522 |
OptionName.EXTDIRS, OptionName.DJAVA_EXT_DIRS); |
|
523 |
} |
|
524 |
||
525 |
boolean isDefault() { |
|
526 |
lazy(); |
|
527 |
return isDefaultBootClassPath; |
|
528 |
} |
|
529 |
||
530 |
boolean isDefaultRtJar(File file) { |
|
531 |
lazy(); |
|
532 |
return file.equals(defaultBootClassPathRtJar); |
|
533 |
} |
|
534 |
||
535 |
@Override |
|
536 |
boolean handleOption(OptionName option, String value) { |
|
537 |
if (!options.contains(option)) |
|
538 |
return false; |
|
10 | 539 |
|
10818 | 540 |
option = canonicalize(option); |
541 |
optionValues.put(option, value); |
|
542 |
if (option == BOOTCLASSPATH) { |
|
543 |
optionValues.remove(XBOOTCLASSPATH_PREPEND); |
|
544 |
optionValues.remove(XBOOTCLASSPATH_APPEND); |
|
545 |
} |
|
546 |
searchPath = null; // reset to "uninitialized" |
|
547 |
return true; |
|
548 |
} |
|
549 |
// where |
|
550 |
// TODO: would be better if option aliasing was handled at a higher |
|
551 |
// level |
|
552 |
private OptionName canonicalize(OptionName option) { |
|
553 |
switch (option) { |
|
554 |
case XBOOTCLASSPATH: |
|
555 |
return OptionName.BOOTCLASSPATH; |
|
556 |
case DJAVA_ENDORSED_DIRS: |
|
557 |
return OptionName.ENDORSEDDIRS; |
|
558 |
case DJAVA_EXT_DIRS: |
|
559 |
return OptionName.EXTDIRS; |
|
560 |
default: |
|
561 |
return option; |
|
562 |
} |
|
563 |
} |
|
10 | 564 |
|
10818 | 565 |
@Override |
566 |
Collection<File> getLocation() { |
|
10 | 567 |
lazy(); |
10818 | 568 |
return searchPath; |
569 |
} |
|
570 |
||
571 |
@Override |
|
572 |
void setLocation(Iterable<? extends File> files) { |
|
573 |
if (files == null) { |
|
574 |
searchPath = null; // reset to "uninitialized" |
|
575 |
} else { |
|
576 |
defaultBootClassPathRtJar = null; |
|
577 |
isDefaultBootClassPath = false; |
|
578 |
Path p = new Path().addFiles(files, false); |
|
579 |
searchPath = Collections.unmodifiableCollection(p); |
|
580 |
optionValues.clear(); |
|
581 |
} |
|
10 | 582 |
} |
10818 | 583 |
|
584 |
Path computePath() { |
|
585 |
defaultBootClassPathRtJar = null; |
|
586 |
Path path = new Path(); |
|
587 |
||
588 |
String bootclasspathOpt = optionValues.get(BOOTCLASSPATH); |
|
589 |
String endorseddirsOpt = optionValues.get(ENDORSEDDIRS); |
|
590 |
String extdirsOpt = optionValues.get(EXTDIRS); |
|
591 |
String xbootclasspathPrependOpt = optionValues.get(XBOOTCLASSPATH_PREPEND); |
|
592 |
String xbootclasspathAppendOpt = optionValues.get(XBOOTCLASSPATH_APPEND); |
|
593 |
||
594 |
path.addFiles(xbootclasspathPrependOpt); |
|
595 |
||
596 |
if (endorseddirsOpt != null) |
|
597 |
path.addDirectories(endorseddirsOpt); |
|
598 |
else |
|
599 |
path.addDirectories(System.getProperty("java.endorsed.dirs"), false); |
|
600 |
||
601 |
if (bootclasspathOpt != null) { |
|
602 |
path.addFiles(bootclasspathOpt); |
|
603 |
} else { |
|
604 |
// Standard system classes for this compiler's release. |
|
605 |
String files = System.getProperty("sun.boot.class.path"); |
|
606 |
path.addFiles(files, false); |
|
607 |
File rt_jar = new File("rt.jar"); |
|
608 |
for (File file : getPathEntries(files)) { |
|
609 |
if (new File(file.getName()).equals(rt_jar)) |
|
610 |
defaultBootClassPathRtJar = file; |
|
611 |
} |
|
612 |
} |
|
613 |
||
614 |
path.addFiles(xbootclasspathAppendOpt); |
|
615 |
||
616 |
// Strictly speaking, standard extensions are not bootstrap |
|
617 |
// classes, but we treat them identically, so we'll pretend |
|
618 |
// that they are. |
|
619 |
if (extdirsOpt != null) |
|
620 |
path.addDirectories(extdirsOpt); |
|
621 |
else |
|
622 |
path.addDirectories(System.getProperty("java.ext.dirs"), false); |
|
623 |
||
624 |
isDefaultBootClassPath = |
|
625 |
(xbootclasspathPrependOpt == null) && |
|
626 |
(bootclasspathOpt == null) && |
|
627 |
(xbootclasspathAppendOpt == null); |
|
628 |
||
629 |
return path; |
|
630 |
} |
|
631 |
||
632 |
private void lazy() { |
|
633 |
if (searchPath == null) |
|
634 |
searchPath = Collections.unmodifiableCollection(computePath()); |
|
635 |
} |
|
10 | 636 |
} |
637 |
||
10818 | 638 |
Map<Location, LocationHandler> handlersForLocation; |
639 |
Map<OptionName, LocationHandler> handlersForOption; |
|
640 |
||
641 |
void initHandlers() { |
|
642 |
handlersForLocation = new HashMap<Location, LocationHandler>(); |
|
643 |
handlersForOption = new EnumMap<OptionName, LocationHandler>(OptionName.class); |
|
644 |
||
645 |
LocationHandler[] handlers = { |
|
646 |
new BootClassPathLocationHandler(), |
|
647 |
new ClassPathLocationHandler(), |
|
648 |
new SimpleLocationHandler(StandardLocation.SOURCE_PATH, OptionName.SOURCEPATH), |
|
649 |
new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_PATH, OptionName.PROCESSORPATH), |
|
650 |
new OutputLocationHandler((StandardLocation.CLASS_OUTPUT), OptionName.D), |
|
651 |
new OutputLocationHandler((StandardLocation.SOURCE_OUTPUT), OptionName.S) |
|
652 |
}; |
|
10 | 653 |
|
10818 | 654 |
for (LocationHandler h: handlers) { |
655 |
handlersForLocation.put(h.location, h); |
|
656 |
for (OptionName o: h.options) |
|
657 |
handlersForOption.put(o, h); |
|
10 | 658 |
} |
10818 | 659 |
} |
660 |
||
661 |
boolean handleOption(OptionName option, String value) { |
|
662 |
LocationHandler h = handlersForOption.get(option); |
|
663 |
return (h == null ? false : h.handleOption(option, value)); |
|
664 |
} |
|
665 |
||
666 |
Collection<File> getLocation(Location location) { |
|
667 |
LocationHandler h = getHandler(location); |
|
668 |
return (h == null ? null : h.getLocation()); |
|
10 | 669 |
} |
670 |
||
10818 | 671 |
File getOutputLocation(Location location) { |
672 |
if (!location.isOutputLocation()) |
|
673 |
throw new IllegalArgumentException(); |
|
674 |
LocationHandler h = getHandler(location); |
|
675 |
return ((OutputLocationHandler) h).outputDir; |
|
676 |
} |
|
10 | 677 |
|
10818 | 678 |
void setLocation(Location location, Iterable<? extends File> files) throws IOException { |
679 |
LocationHandler h = getHandler(location); |
|
680 |
if (h == null) { |
|
681 |
if (location.isOutputLocation()) |
|
682 |
h = new OutputLocationHandler(location); |
|
683 |
else |
|
684 |
h = new SimpleLocationHandler(location); |
|
685 |
handlersForLocation.put(location, h); |
|
686 |
} |
|
687 |
h.setLocation(files); |
|
688 |
} |
|
689 |
||
690 |
protected LocationHandler getHandler(Location location) { |
|
691 |
location.getClass(); // null check |
|
692 |
lazy(); |
|
693 |
return handlersForLocation.get(location); |
|
694 |
} |
|
695 |
||
696 |
// TOGO |
|
697 |
protected void lazy() { |
|
698 |
if (!inited) { |
|
699 |
warn = lint.isEnabled(Lint.LintCategory.PATH); |
|
700 |
||
701 |
for (LocationHandler h: handlersForLocation.values()) { |
|
702 |
h.update(options); |
|
10 | 703 |
} |
10818 | 704 |
|
705 |
inited = true; |
|
10 | 706 |
} |
707 |
} |
|
708 |
||
709 |
/** Is this the name of an archive file? */ |
|
1208 | 710 |
private boolean isArchive(File file) { |
10 | 711 |
String n = file.getName().toLowerCase(); |
1208 | 712 |
return fsInfo.isFile(file) |
10 | 713 |
&& (n.endsWith(".jar") || n.endsWith(".zip")); |
714 |
} |
|
4937
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
715 |
|
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
716 |
/** |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
717 |
* Utility method for converting a search path string to an array |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
718 |
* of directory and JAR file URLs. |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
719 |
* |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
720 |
* Note that this method is called by apt and the DocletInvoker. |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
721 |
* |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
722 |
* @param path the search path string |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
723 |
* @return the resulting array of directory and JAR file URLs |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
724 |
*/ |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
725 |
public static URL[] pathToURLs(String path) { |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
726 |
StringTokenizer st = new StringTokenizer(path, File.pathSeparator); |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
727 |
URL[] urls = new URL[st.countTokens()]; |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
728 |
int count = 0; |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
729 |
while (st.hasMoreTokens()) { |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
730 |
URL url = fileToURL(new File(st.nextToken())); |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
731 |
if (url != null) { |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
732 |
urls[count++] = url; |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
733 |
} |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
734 |
} |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
735 |
if (urls.length != count) { |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
736 |
URL[] tmp = new URL[count]; |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
737 |
System.arraycopy(urls, 0, tmp, 0, count); |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
738 |
urls = tmp; |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
739 |
} |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
740 |
return urls; |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
741 |
} |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
742 |
|
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
743 |
/** |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
744 |
* Returns the directory or JAR file URL corresponding to the specified |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
745 |
* local file name. |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
746 |
* |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
747 |
* @param file the File object |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
748 |
* @return the resulting directory or JAR file URL, or null if unknown |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
749 |
*/ |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
750 |
private static URL fileToURL(File file) { |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
751 |
String name; |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
752 |
try { |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
753 |
name = file.getCanonicalPath(); |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
754 |
} catch (IOException e) { |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
755 |
name = file.getAbsolutePath(); |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
756 |
} |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
757 |
name = name.replace(File.separatorChar, '/'); |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
758 |
if (!name.startsWith("/")) { |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
759 |
name = "/" + name; |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
760 |
} |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
761 |
// If the file does not exist, then assume that it's a directory |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
762 |
if (!file.isFile()) { |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
763 |
name = name + "/"; |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
764 |
} |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
765 |
try { |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
766 |
return new URL("file", "", name); |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
767 |
} catch (MalformedURLException e) { |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
768 |
throw new IllegalArgumentException(file.toString()); |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
769 |
} |
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
770 |
} |
10 | 771 |
} |