author | jlahoda |
Mon, 06 Mar 2017 13:17:33 +0100 | |
changeset 44063 | 5f0cf4126949 |
parent 44021 | 3ea5514d9fbe |
child 44573 | 245bb4e6f983 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
43267 | 2 |
* Copyright (c) 2003, 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 |
*/ |
34752
9c262a013456
8145342: Some copyright notices are inconsistently and ill formatted
vasya
parents:
29780
diff
changeset
|
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 |
|
36526 | 28 |
import java.io.Closeable; |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
29 |
import java.io.File; |
10818 | 30 |
import java.io.FileNotFoundException; |
10 | 31 |
import java.io.IOException; |
27579 | 32 |
import java.io.UncheckedIOException; |
36526 | 33 |
import java.net.URI; |
4937
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
34 |
import java.net.URL; |
36526 | 35 |
import java.net.URLClassLoader; |
36 |
import java.nio.file.DirectoryIteratorException; |
|
37 |
import java.nio.file.DirectoryStream; |
|
38 |
import java.nio.file.FileSystem; |
|
39 |
import java.nio.file.FileSystemNotFoundException; |
|
40 |
import java.nio.file.FileSystems; |
|
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
41 |
import java.nio.file.Files; |
41861
8c58faf4f03b
8132562: javac fails with CLASSPATH with double-quotes as an environment variable
vromero
parents:
41637
diff
changeset
|
42 |
import java.nio.file.InvalidPathException; |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
43 |
import java.nio.file.Path; |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
44 |
import java.nio.file.Paths; |
36526 | 45 |
import java.nio.file.ProviderNotFoundException; |
43574
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
43267
diff
changeset
|
46 |
import java.nio.file.spi.FileSystemProvider; |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
47 |
import java.util.ArrayList; |
10818 | 48 |
import java.util.Arrays; |
49 |
import java.util.Collection; |
|
50 |
import java.util.Collections; |
|
51 |
import java.util.EnumMap; |
|
52 |
import java.util.EnumSet; |
|
10 | 53 |
import java.util.HashMap; |
54 |
import java.util.HashSet; |
|
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
55 |
import java.util.Iterator; |
36526 | 56 |
import java.util.LinkedHashMap; |
10818 | 57 |
import java.util.LinkedHashSet; |
36526 | 58 |
import java.util.List; |
10 | 59 |
import java.util.Map; |
29291
076c277565f7
8073550: java* tools: replace obj.getClass hacks with Assert.checkNonNull or Objects.requireNonNull
mcimadamore
parents:
29053
diff
changeset
|
60 |
import java.util.Objects; |
36526 | 61 |
import java.util.NoSuchElementException; |
10 | 62 |
import java.util.Set; |
44063
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
63 |
import java.util.function.Predicate; |
36526 | 64 |
import java.util.regex.Matcher; |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
65 |
import java.util.regex.Pattern; |
27579 | 66 |
import java.util.stream.Collectors; |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
67 |
import java.util.stream.Stream; |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
68 |
|
36526 | 69 |
import javax.lang.model.SourceVersion; |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
70 |
import javax.tools.JavaFileManager; |
10 | 71 |
import javax.tools.JavaFileManager.Location; |
41861
8c58faf4f03b
8132562: javac fails with CLASSPATH with double-quotes as an environment variable
vromero
parents:
41637
diff
changeset
|
72 |
import javax.tools.JavaFileObject; |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
73 |
import javax.tools.StandardJavaFileManager; |
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
74 |
import javax.tools.StandardJavaFileManager.PathFactory; |
10818 | 75 |
import javax.tools.StandardLocation; |
10 | 76 |
|
731
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
171
diff
changeset
|
77 |
import com.sun.tools.javac.code.Lint; |
42837
03ee805ba348
8169005: tools/javac/T8132562/ClassPathWithDoubleQuotesTest.java fails after fix to JDK-8132562
vromero
parents:
42827
diff
changeset
|
78 |
import com.sun.tools.javac.code.Lint.LintCategory; |
11314 | 79 |
import com.sun.tools.javac.main.Option; |
36526 | 80 |
import com.sun.tools.javac.resources.CompilerProperties.Errors; |
81 |
import com.sun.tools.javac.resources.CompilerProperties.Warnings; |
|
37848
3c8ff4204d2d
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36526
diff
changeset
|
82 |
import com.sun.tools.javac.util.DefinedBy; |
3c8ff4204d2d
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36526
diff
changeset
|
83 |
import com.sun.tools.javac.util.DefinedBy.Api; |
41440 | 84 |
import com.sun.tools.javac.util.JDK9Wrappers; |
1486 | 85 |
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
|
86 |
import com.sun.tools.javac.util.Log; |
41254
08f8dbf7741e
8152911: javac assertion error when compiling overlay sources
jlahoda
parents:
41155
diff
changeset
|
87 |
import com.sun.tools.javac.jvm.ModuleNameReader; |
36526 | 88 |
import com.sun.tools.javac.util.Pair; |
22153
f9f06fcca59d
8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents:
14360
diff
changeset
|
89 |
import com.sun.tools.javac.util.StringUtils; |
731
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
171
diff
changeset
|
90 |
|
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
91 |
import static javax.tools.StandardLocation.PLATFORM_CLASS_PATH; |
10 | 92 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40302
diff
changeset
|
93 |
import static com.sun.tools.javac.main.Option.BOOT_CLASS_PATH; |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
94 |
import static com.sun.tools.javac.main.Option.DJAVA_ENDORSED_DIRS; |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
95 |
import static com.sun.tools.javac.main.Option.DJAVA_EXT_DIRS; |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
96 |
import static com.sun.tools.javac.main.Option.ENDORSEDDIRS; |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
97 |
import static com.sun.tools.javac.main.Option.EXTDIRS; |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
98 |
import static com.sun.tools.javac.main.Option.XBOOTCLASSPATH; |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
99 |
import static com.sun.tools.javac.main.Option.XBOOTCLASSPATH_APPEND; |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
100 |
import static com.sun.tools.javac.main.Option.XBOOTCLASSPATH_PREPEND; |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
101 |
|
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
102 |
/** |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
103 |
* This class converts command line arguments, environment variables and system properties (in |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
104 |
* File.pathSeparator-separated String form) into a boot class path, user class path, and source |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
105 |
* path (in {@code Collection<String>} form). |
10 | 106 |
* |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
107 |
* <p> |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
108 |
* <b>This is NOT part of any supported API. If you write code that depends on this, you do so at |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
109 |
* your own risk. This code and its internal interfaces are subject to change or deletion without |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
110 |
* notice.</b> |
10 | 111 |
*/ |
10818 | 112 |
public class Locations { |
10 | 113 |
|
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
114 |
/** |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
115 |
* The log to use for warning output |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
116 |
*/ |
10 | 117 |
private Log log; |
118 |
||
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
119 |
/** |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
120 |
* Access to (possibly cached) file info |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
121 |
*/ |
1208 | 122 |
private FSInfo fsInfo; |
10 | 123 |
|
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
124 |
/** |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
125 |
* Whether to warn about non-existent path elements |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
126 |
*/ |
10818 | 127 |
private boolean warn; |
128 |
||
36526 | 129 |
private ModuleNameReader moduleNameReader; |
130 |
||
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
131 |
private PathFactory pathFactory = Paths::get; |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
132 |
|
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
133 |
static final Path javaHome = FileSystems.getDefault().getPath(System.getProperty("java.home")); |
36526 | 134 |
static final Path thisSystemModules = javaHome.resolve("lib").resolve("modules"); |
135 |
||
136 |
Map<Path, FileSystem> fileSystems = new LinkedHashMap<>(); |
|
137 |
List<Closeable> closeables = new ArrayList<>(); |
|
41155
93dad90c22c1
8156568: Update javac to support compiling against a modular JAR that is a multi-release JAR
sadayapalam
parents:
40762
diff
changeset
|
138 |
private Map<String,String> fsEnv = Collections.emptyMap(); |
27579 | 139 |
|
29780
8f8e54a1fa20
8076420: Consolidate javac file handling in javac.file package
jjg
parents:
29291
diff
changeset
|
140 |
Locations() { |
10818 | 141 |
initHandlers(); |
10 | 142 |
} |
143 |
||
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
144 |
Path getPath(String first, String... more) { |
41861
8c58faf4f03b
8132562: javac fails with CLASSPATH with double-quotes as an environment variable
vromero
parents:
41637
diff
changeset
|
145 |
try { |
8c58faf4f03b
8132562: javac fails with CLASSPATH with double-quotes as an environment variable
vromero
parents:
41637
diff
changeset
|
146 |
return pathFactory.getPath(first, more); |
8c58faf4f03b
8132562: javac fails with CLASSPATH with double-quotes as an environment variable
vromero
parents:
41637
diff
changeset
|
147 |
} catch (InvalidPathException ipe) { |
8c58faf4f03b
8132562: javac fails with CLASSPATH with double-quotes as an environment variable
vromero
parents:
41637
diff
changeset
|
148 |
throw new IllegalArgumentException(ipe); |
8c58faf4f03b
8132562: javac fails with CLASSPATH with double-quotes as an environment variable
vromero
parents:
41637
diff
changeset
|
149 |
} |
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
150 |
} |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
151 |
|
36526 | 152 |
public void close() throws IOException { |
153 |
ListBuffer<IOException> list = new ListBuffer<>(); |
|
154 |
closeables.forEach(closeable -> { |
|
155 |
try { |
|
156 |
closeable.close(); |
|
157 |
} catch (IOException ex) { |
|
158 |
list.add(ex); |
|
159 |
} |
|
160 |
}); |
|
161 |
if (list.nonEmpty()) { |
|
162 |
IOException ex = new IOException(); |
|
163 |
for (IOException e: list) |
|
164 |
ex.addSuppressed(e); |
|
165 |
throw ex; |
|
166 |
} |
|
167 |
} |
|
168 |
||
41637 | 169 |
void update(Log log, boolean warn, FSInfo fsInfo) { |
10813
95b39a692cd0
7101146: Paths should more directly managed by BaseFileManager
jjg
parents:
8424
diff
changeset
|
170 |
this.log = log; |
41637 | 171 |
this.warn = warn; |
10813
95b39a692cd0
7101146: Paths should more directly managed by BaseFileManager
jjg
parents:
8424
diff
changeset
|
172 |
this.fsInfo = fsInfo; |
10 | 173 |
} |
174 |
||
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
175 |
void setPathFactory(PathFactory f) { |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
176 |
pathFactory = f; |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
177 |
} |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
178 |
|
29780
8f8e54a1fa20
8076420: Consolidate javac file handling in javac.file package
jjg
parents:
29291
diff
changeset
|
179 |
boolean isDefaultBootClassPath() { |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
180 |
BootClassPathLocationHandler h |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
181 |
= (BootClassPathLocationHandler) getHandler(PLATFORM_CLASS_PATH); |
10818 | 182 |
return h.isDefault(); |
10 | 183 |
} |
184 |
||
1486 | 185 |
/** |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
186 |
* Split a search path into its elements. Empty path elements will be ignored. |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
187 |
* |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
188 |
* @param searchPath The search path to be split |
1486 | 189 |
* @return The elements of the path |
190 |
*/ |
|
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
191 |
private Iterable<Path> getPathEntries(String searchPath) { |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
192 |
return getPathEntries(searchPath, null); |
1486 | 193 |
} |
10 | 194 |
|
1486 | 195 |
/** |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
196 |
* Split a search path into its elements. If emptyPathDefault is not null, all empty elements in the |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
197 |
* path, including empty elements at either end of the path, will be replaced with the value of |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
198 |
* emptyPathDefault. |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
199 |
* |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
200 |
* @param searchPath The search path to be split |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
201 |
* @param emptyPathDefault The value to substitute for empty path elements, or null, to ignore |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
202 |
* empty path elements |
1486 | 203 |
* @return The elements of the path |
204 |
*/ |
|
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
205 |
private Iterable<Path> getPathEntries(String searchPath, Path emptyPathDefault) { |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
206 |
ListBuffer<Path> entries = new ListBuffer<>(); |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
207 |
for (String s: searchPath.split(Pattern.quote(File.pathSeparator), -1)) { |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
208 |
if (s.isEmpty()) { |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
209 |
if (emptyPathDefault != null) { |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
210 |
entries.add(emptyPathDefault); |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
211 |
} |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
212 |
} else { |
42837
03ee805ba348
8169005: tools/javac/T8132562/ClassPathWithDoubleQuotesTest.java fails after fix to JDK-8132562
vromero
parents:
42827
diff
changeset
|
213 |
try { |
03ee805ba348
8169005: tools/javac/T8132562/ClassPathWithDoubleQuotesTest.java fails after fix to JDK-8132562
vromero
parents:
42827
diff
changeset
|
214 |
entries.add(getPath(s)); |
03ee805ba348
8169005: tools/javac/T8132562/ClassPathWithDoubleQuotesTest.java fails after fix to JDK-8132562
vromero
parents:
42827
diff
changeset
|
215 |
} catch (IllegalArgumentException e) { |
03ee805ba348
8169005: tools/javac/T8132562/ClassPathWithDoubleQuotesTest.java fails after fix to JDK-8132562
vromero
parents:
42827
diff
changeset
|
216 |
if (warn) { |
03ee805ba348
8169005: tools/javac/T8132562/ClassPathWithDoubleQuotesTest.java fails after fix to JDK-8132562
vromero
parents:
42827
diff
changeset
|
217 |
log.warning(LintCategory.PATH, "invalid.path", s); |
03ee805ba348
8169005: tools/javac/T8132562/ClassPathWithDoubleQuotesTest.java fails after fix to JDK-8132562
vromero
parents:
42827
diff
changeset
|
218 |
} |
03ee805ba348
8169005: tools/javac/T8132562/ClassPathWithDoubleQuotesTest.java fails after fix to JDK-8132562
vromero
parents:
42827
diff
changeset
|
219 |
} |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
220 |
} |
10 | 221 |
} |
1486 | 222 |
return entries; |
10 | 223 |
} |
224 |
||
41155
93dad90c22c1
8156568: Update javac to support compiling against a modular JAR that is a multi-release JAR
sadayapalam
parents:
40762
diff
changeset
|
225 |
public void setMultiReleaseValue(String multiReleaseValue) { |
93dad90c22c1
8156568: Update javac to support compiling against a modular JAR that is a multi-release JAR
sadayapalam
parents:
40762
diff
changeset
|
226 |
fsEnv = Collections.singletonMap("multi-release", multiReleaseValue); |
93dad90c22c1
8156568: Update javac to support compiling against a modular JAR that is a multi-release JAR
sadayapalam
parents:
40762
diff
changeset
|
227 |
} |
93dad90c22c1
8156568: Update javac to support compiling against a modular JAR that is a multi-release JAR
sadayapalam
parents:
40762
diff
changeset
|
228 |
|
10818 | 229 |
/** |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
230 |
* Utility class to help evaluate a path option. Duplicate entries are ignored, jar class paths |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
231 |
* can be expanded. |
10818 | 232 |
*/ |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
233 |
private class SearchPath extends LinkedHashSet<Path> { |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
234 |
|
10 | 235 |
private static final long serialVersionUID = 0; |
236 |
||
237 |
private boolean expandJarClassPaths = false; |
|
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
238 |
private final Set<Path> canonicalValues = new HashSet<>(); |
10 | 239 |
|
27118
3c8314271af7
8060043: Rename Locations.Path to Locations.SearchPath
jjg
parents:
25874
diff
changeset
|
240 |
public SearchPath expandJarClassPaths(boolean x) { |
10 | 241 |
expandJarClassPaths = x; |
242 |
return this; |
|
243 |
} |
|
244 |
||
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
245 |
/** |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
246 |
* What to use when path element is the empty string |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
247 |
*/ |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
248 |
private Path emptyPathDefault = null; |
10 | 249 |
|
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
250 |
public SearchPath emptyPathDefault(Path x) { |
10 | 251 |
emptyPathDefault = x; |
252 |
return this; |
|
253 |
} |
|
254 |
||
27118
3c8314271af7
8060043: Rename Locations.Path to Locations.SearchPath
jjg
parents:
25874
diff
changeset
|
255 |
public SearchPath addDirectories(String dirs, boolean warn) { |
8424
5e31b2eb5aa3
6485027: javac incorrectly handles relative paths in manifest classpath
jjg
parents:
8034
diff
changeset
|
256 |
boolean prev = expandJarClassPaths; |
5e31b2eb5aa3
6485027: javac incorrectly handles relative paths in manifest classpath
jjg
parents:
8034
diff
changeset
|
257 |
expandJarClassPaths = true; |
5e31b2eb5aa3
6485027: javac incorrectly handles relative paths in manifest classpath
jjg
parents:
8034
diff
changeset
|
258 |
try { |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
259 |
if (dirs != null) { |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
260 |
for (Path dir : getPathEntries(dirs)) { |
8424
5e31b2eb5aa3
6485027: javac incorrectly handles relative paths in manifest classpath
jjg
parents:
8034
diff
changeset
|
261 |
addDirectory(dir, warn); |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
262 |
} |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
263 |
} |
8424
5e31b2eb5aa3
6485027: javac incorrectly handles relative paths in manifest classpath
jjg
parents:
8034
diff
changeset
|
264 |
return this; |
5e31b2eb5aa3
6485027: javac incorrectly handles relative paths in manifest classpath
jjg
parents:
8034
diff
changeset
|
265 |
} finally { |
5e31b2eb5aa3
6485027: javac incorrectly handles relative paths in manifest classpath
jjg
parents:
8034
diff
changeset
|
266 |
expandJarClassPaths = prev; |
5e31b2eb5aa3
6485027: javac incorrectly handles relative paths in manifest classpath
jjg
parents:
8034
diff
changeset
|
267 |
} |
10 | 268 |
} |
269 |
||
27118
3c8314271af7
8060043: Rename Locations.Path to Locations.SearchPath
jjg
parents:
25874
diff
changeset
|
270 |
public SearchPath addDirectories(String dirs) { |
10 | 271 |
return addDirectories(dirs, warn); |
272 |
} |
|
273 |
||
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
274 |
private void addDirectory(Path dir, boolean warn) { |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
275 |
if (!Files.isDirectory(dir)) { |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
276 |
if (warn) { |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
277 |
log.warning(Lint.LintCategory.PATH, |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
278 |
"dir.path.element.not.found", dir); |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
279 |
} |
10 | 280 |
return; |
281 |
} |
|
282 |
||
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
283 |
try (Stream<Path> s = Files.list(dir)) { |
42827
36468b5fa7f4
8181370: Convert anonymous inner classes into lambdas/method references
mcimadamore
parents:
42814
diff
changeset
|
284 |
s.filter(Locations.this::isArchive) |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
285 |
.forEach(dirEntry -> addFile(dirEntry, warn)); |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
286 |
} catch (IOException ignore) { |
10 | 287 |
} |
288 |
} |
|
289 |
||
27118
3c8314271af7
8060043: Rename Locations.Path to Locations.SearchPath
jjg
parents:
25874
diff
changeset
|
290 |
public SearchPath 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
|
291 |
if (files != null) { |
10818 | 292 |
addFiles(getPathEntries(files, emptyPathDefault), warn); |
293 |
} |
|
294 |
return this; |
|
295 |
} |
|
296 |
||
27118
3c8314271af7
8060043: Rename Locations.Path to Locations.SearchPath
jjg
parents:
25874
diff
changeset
|
297 |
public SearchPath addFiles(String files) { |
10818 | 298 |
return addFiles(files, warn); |
299 |
} |
|
300 |
||
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
301 |
public SearchPath addFiles(Iterable<? extends Path> files, boolean warn) { |
10818 | 302 |
if (files != null) { |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
303 |
for (Path file : files) { |
10 | 304 |
addFile(file, warn); |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
305 |
} |
7335
8b390fd27190
6900037: javac should warn if earlier -source is used and bootclasspath not set
jjg
parents:
6151
diff
changeset
|
306 |
} |
10 | 307 |
return this; |
308 |
} |
|
309 |
||
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
310 |
public SearchPath addFiles(Iterable<? extends Path> files) { |
10 | 311 |
return addFiles(files, warn); |
312 |
} |
|
313 |
||
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
314 |
public void addFile(Path 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
|
315 |
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
|
316 |
// discard duplicates |
10 | 317 |
return; |
318 |
} |
|
319 |
||
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
320 |
if (!fsInfo.exists(file)) { |
10 | 321 |
/* No such file or directory exists */ |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
322 |
if (warn) { |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
323 |
log.warning(Lint.LintCategory.PATH, |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
324 |
"path.element.not.found", file); |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
325 |
} |
7839
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
326 |
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
|
327 |
return; |
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
328 |
} |
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
329 |
|
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
330 |
Path canonFile = fsInfo.getCanonicalFile(file); |
7839
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
331 |
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
|
332 |
/* 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
|
333 |
return; |
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
334 |
} |
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
335 |
|
a1ca72d05b20
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
jjh
parents:
7336
diff
changeset
|
336 |
if (fsInfo.isFile(file)) { |
10 | 337 |
/* File is an ordinary file. */ |
40513
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
338 |
if ( !file.getFileName().toString().endsWith(".jmod") |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
339 |
&& !file.endsWith("modules")) { |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
340 |
if (!isArchive(file)) { |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
341 |
/* Not a recognized extension; open it to see if |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
342 |
it looks like a valid zip file. */ |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
343 |
try { |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
344 |
FileSystems.newFileSystem(file, null).close(); |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
345 |
if (warn) { |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
346 |
log.warning(Lint.LintCategory.PATH, |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
347 |
"unexpected.archive.file", file); |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
348 |
} |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
349 |
} catch (IOException | ProviderNotFoundException e) { |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
350 |
// FIXME: include e.getLocalizedMessage in warning |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
351 |
if (warn) { |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
352 |
log.warning(Lint.LintCategory.PATH, |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
353 |
"invalid.archive.file", file); |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
354 |
} |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
355 |
return; |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
356 |
} |
40513
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
357 |
} else { |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
358 |
if (fsInfo.getJarFSProvider() == null) { |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
359 |
log.error(Errors.NoZipfsForArchive(file)); |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
40308
diff
changeset
|
360 |
return ; |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
361 |
} |
10 | 362 |
} |
363 |
} |
|
364 |
} |
|
365 |
||
366 |
/* Now what we have left is either a directory or a file name |
|
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
367 |
conforming to archive naming convention */ |
10 | 368 |
super.add(file); |
1208 | 369 |
canonicalValues.add(canonFile); |
10 | 370 |
|
36526 | 371 |
if (expandJarClassPaths && fsInfo.isFile(file) && !file.endsWith("modules")) { |
10 | 372 |
addJarClassPath(file, warn); |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
373 |
} |
10 | 374 |
} |
375 |
||
376 |
// Adds referenced classpath elements from a jar's Class-Path |
|
377 |
// Manifest entry. In some future release, we may want to |
|
378 |
// update this code to recognize URLs rather than simple |
|
379 |
// filenames, but if we do, we should redo all path-related code. |
|
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
380 |
private void addJarClassPath(Path jarFile, boolean warn) { |
10 | 381 |
try { |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
382 |
for (Path f : fsInfo.getJarClassPath(jarFile)) { |
1208 | 383 |
addFile(f, warn); |
10 | 384 |
} |
385 |
} catch (IOException e) { |
|
5007
28dee2489196
6930076: "null" can incorrectly appear in error message compiler.err.error.reading.file
jjg
parents:
4937
diff
changeset
|
386 |
log.error("error.reading.file", jarFile, JavacFileManager.getMessage(e)); |
10 | 387 |
} |
388 |
} |
|
389 |
} |
|
390 |
||
10818 | 391 |
/** |
36526 | 392 |
* Base class for handling support for the representation of Locations. |
393 |
* |
|
394 |
* Locations are (by design) opaque handles that can easily be implemented |
|
395 |
* by enums like StandardLocation. Within JavacFileManager, each Location |
|
396 |
* has an associated LocationHandler, which provides much of the appropriate |
|
397 |
* functionality for the corresponding Location. |
|
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
398 |
* |
10818 | 399 |
* @see #initHandlers |
400 |
* @see #getHandler |
|
401 |
*/ |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
402 |
protected static abstract class LocationHandler { |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
403 |
|
36526 | 404 |
/** |
405 |
* @see JavaFileManager#handleOption |
|
406 |
*/ |
|
407 |
abstract boolean handleOption(Option option, String value); |
|
408 |
||
409 |
/** |
|
410 |
* @see StandardJavaFileManager#hasLocation |
|
411 |
*/ |
|
412 |
boolean isSet() { |
|
413 |
return (getPaths() != null); |
|
414 |
} |
|
415 |
||
416 |
/** |
|
417 |
* @see StandardJavaFileManager#getLocation |
|
418 |
*/ |
|
419 |
abstract Collection<Path> getPaths(); |
|
420 |
||
421 |
/** |
|
422 |
* @see StandardJavaFileManager#setLocation |
|
423 |
*/ |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
424 |
abstract void setPaths(Iterable<? extends Path> paths) throws IOException; |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
425 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
426 |
/** |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
427 |
* @see StandardJavaFileManager#setLocationForModule |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
428 |
*/ |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
429 |
abstract void setPathsForModule(String moduleName, Iterable<? extends Path> paths) |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
430 |
throws IOException; |
36526 | 431 |
|
432 |
/** |
|
42261
bb52b5514ad5
8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents:
41861
diff
changeset
|
433 |
* @see JavaFileManager#getLocationForModule(Location, String) |
36526 | 434 |
*/ |
42261
bb52b5514ad5
8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents:
41861
diff
changeset
|
435 |
Location getLocationForModule(String moduleName) throws IOException { |
36526 | 436 |
return null; |
437 |
} |
|
438 |
||
439 |
/** |
|
42261
bb52b5514ad5
8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents:
41861
diff
changeset
|
440 |
* @see JavaFileManager#getLocationForModule(Location, JavaFileObject, String) |
36526 | 441 |
*/ |
44063
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
442 |
Location getLocationForModule(Path file) throws IOException { |
36526 | 443 |
return null; |
444 |
} |
|
445 |
||
446 |
/** |
|
447 |
* @see JavaFileManager#inferModuleName |
|
448 |
*/ |
|
449 |
String inferModuleName() { |
|
450 |
return null; |
|
451 |
} |
|
452 |
||
453 |
/** |
|
42261
bb52b5514ad5
8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents:
41861
diff
changeset
|
454 |
* @see JavaFileManager#listLocationsForModules |
36526 | 455 |
*/ |
42261
bb52b5514ad5
8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents:
41861
diff
changeset
|
456 |
Iterable<Set<Location>> listLocationsForModules() throws IOException { |
36526 | 457 |
return null; |
458 |
} |
|
459 |
} |
|
460 |
||
461 |
/** |
|
462 |
* A LocationHandler for a given Location, and associated set of options. |
|
463 |
*/ |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
464 |
private static abstract class BasicLocationHandler extends LocationHandler { |
36526 | 465 |
|
10818 | 466 |
final Location location; |
11314 | 467 |
final Set<Option> options; |
7335
8b390fd27190
6900037: javac should warn if earlier -source is used and bootclasspath not set
jjg
parents:
6151
diff
changeset
|
468 |
|
10818 | 469 |
/** |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
470 |
* Create a handler. The location and options provide a way to map from a location or an |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
471 |
* option to the corresponding handler. |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
472 |
* |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
473 |
* @param location the location for which this is the handler |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
474 |
* @param options the options affecting this location |
10818 | 475 |
* @see #initHandlers |
476 |
*/ |
|
36526 | 477 |
protected BasicLocationHandler(Location location, Option... options) { |
10818 | 478 |
this.location = location; |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
479 |
this.options = options.length == 0 |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
480 |
? EnumSet.noneOf(Option.class) |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
481 |
: EnumSet.copyOf(Arrays.asList(options)); |
10818 | 482 |
} |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
483 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
484 |
@Override |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
485 |
void setPathsForModule(String moduleName, Iterable<? extends Path> files) throws IOException { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
486 |
// should not happen: protected by check in JavacFileManager |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
487 |
throw new UnsupportedOperationException("not supported for " + location); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
488 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
489 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
490 |
protected Path checkSingletonDirectory(Iterable<? extends Path> paths) throws IOException { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
491 |
Iterator<? extends Path> pathIter = paths.iterator(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
492 |
if (!pathIter.hasNext()) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
493 |
throw new IllegalArgumentException("empty path for directory"); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
494 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
495 |
Path path = pathIter.next(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
496 |
if (pathIter.hasNext()) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
497 |
throw new IllegalArgumentException("path too long for directory"); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
498 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
499 |
checkDirectory(path); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
500 |
return path; |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
501 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
502 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
503 |
protected Path checkDirectory(Path path) throws IOException { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
504 |
Objects.requireNonNull(path); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
505 |
if (!Files.exists(path)) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
506 |
throw new FileNotFoundException(path + ": does not exist"); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
507 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
508 |
if (!Files.isDirectory(path)) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
509 |
throw new IOException(path + ": not a directory"); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
510 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
511 |
return path; |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
512 |
} |
10818 | 513 |
} |
514 |
||
515 |
/** |
|
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
516 |
* General purpose implementation for output locations, such as -d/CLASS_OUTPUT and |
36526 | 517 |
* -s/SOURCE_OUTPUT. All options are treated as equivalent (i.e. aliases.) |
518 |
* The value is a single file, possibly null. |
|
10818 | 519 |
*/ |
36526 | 520 |
private class OutputLocationHandler extends BasicLocationHandler { |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
521 |
|
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
522 |
private Path outputDir; |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
523 |
private ModuleTable moduleTable; |
10818 | 524 |
|
11314 | 525 |
OutputLocationHandler(Location location, Option... options) { |
10818 | 526 |
super(location, options); |
527 |
} |
|
528 |
||
529 |
@Override |
|
11314 | 530 |
boolean handleOption(Option option, String value) { |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
531 |
if (!options.contains(option)) { |
10818 | 532 |
return false; |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
533 |
} |
10 | 534 |
|
10818 | 535 |
// TODO: could/should validate outputDir exists and is a directory |
536 |
// need to decide how best to report issue for benefit of |
|
537 |
// direct API call on JavaFileManager.handleOption(specifies IAE) |
|
538 |
// vs. command line decoding. |
|
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
539 |
outputDir = (value == null) ? null : getPath(value); |
10818 | 540 |
return true; |
541 |
} |
|
542 |
||
543 |
@Override |
|
36526 | 544 |
Collection<Path> getPaths() { |
10818 | 545 |
return (outputDir == null) ? null : Collections.singleton(outputDir); |
546 |
} |
|
10 | 547 |
|
10818 | 548 |
@Override |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
549 |
void setPaths(Iterable<? extends Path> paths) throws IOException { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
550 |
if (paths == null) { |
10818 | 551 |
outputDir = null; |
552 |
} else { |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
553 |
outputDir = checkSingletonDirectory(paths); |
10818 | 554 |
} |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
555 |
moduleTable = null; |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
556 |
listed = false; |
36526 | 557 |
} |
558 |
||
559 |
@Override |
|
42261
bb52b5514ad5
8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents:
41861
diff
changeset
|
560 |
Location getLocationForModule(String name) { |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
561 |
if (moduleTable == null) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
562 |
moduleTable = new ModuleTable(); |
42814
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
563 |
} |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
564 |
ModuleLocationHandler l = moduleTable.get(name); |
36526 | 565 |
if (l == null) { |
42814
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
566 |
Path out = outputDir.resolve(name); |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
567 |
l = new ModuleLocationHandler(this, location.getName() + "[" + name + "]", |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
568 |
name, Collections.singletonList(out), true); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
569 |
moduleTable.add(l); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
570 |
} |
42814
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
571 |
return l; |
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
572 |
} |
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
573 |
|
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
574 |
@Override |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
575 |
void setPathsForModule(String name, Iterable<? extends Path> paths) throws IOException { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
576 |
Path out = checkSingletonDirectory(paths); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
577 |
if (moduleTable == null) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
578 |
moduleTable = new ModuleTable(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
579 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
580 |
ModuleLocationHandler l = moduleTable.get(name); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
581 |
if (l == null) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
582 |
l = new ModuleLocationHandler(this, location.getName() + "[" + name + "]", |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
583 |
name, Collections.singletonList(out), true); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
584 |
moduleTable.add(l); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
585 |
} else { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
586 |
l.searchPath = Collections.singletonList(out); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
587 |
moduleTable.updatePaths(l); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
588 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
589 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
590 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
591 |
@Override |
44063
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
592 |
Location getLocationForModule(Path file) { |
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
593 |
return (moduleTable == null) ? null : moduleTable.get(file); |
42814
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
594 |
} |
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
595 |
|
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
596 |
private boolean listed; |
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
597 |
|
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
598 |
@Override |
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
599 |
Iterable<Set<Location>> listLocationsForModules() throws IOException { |
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
600 |
if (!listed && outputDir != null) { |
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
601 |
try (DirectoryStream<Path> stream = Files.newDirectoryStream(outputDir)) { |
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
602 |
for (Path p : stream) { |
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
603 |
getLocationForModule(p.getFileName().toString()); |
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
604 |
} |
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
605 |
} |
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
606 |
listed = true; |
36526 | 607 |
} |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
608 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
609 |
if (moduleTable == null || moduleTable.isEmpty()) |
42814
058fc03646d9
8171005: Fix JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName) to work with location == CLASS_OUTPUT
jlahoda
parents:
42414
diff
changeset
|
610 |
return Collections.emptySet(); |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
611 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
612 |
return Collections.singleton(moduleTable.locations()); |
10818 | 613 |
} |
10 | 614 |
} |
615 |
||
10818 | 616 |
/** |
36526 | 617 |
* General purpose implementation for search path locations, |
618 |
* such as -sourcepath/SOURCE_PATH and -processorPath/ANNOTATION_PROCESSOR_PATH. |
|
619 |
* All options are treated as equivalent (i.e. aliases.) |
|
10818 | 620 |
* The value is an ordered set of files and/or directories. |
621 |
*/ |
|
36526 | 622 |
private class SimpleLocationHandler extends BasicLocationHandler { |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
623 |
|
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
624 |
protected Collection<Path> searchPath; |
10 | 625 |
|
11314 | 626 |
SimpleLocationHandler(Location location, Option... options) { |
10818 | 627 |
super(location, options); |
628 |
} |
|
10 | 629 |
|
10818 | 630 |
@Override |
11314 | 631 |
boolean handleOption(Option option, String value) { |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
632 |
if (!options.contains(option)) { |
10818 | 633 |
return false; |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
634 |
} |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
635 |
searchPath = value == null ? null |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
636 |
: Collections.unmodifiableCollection(createPath().addFiles(value)); |
10818 | 637 |
return true; |
638 |
} |
|
639 |
||
640 |
@Override |
|
36526 | 641 |
Collection<Path> getPaths() { |
10818 | 642 |
return searchPath; |
643 |
} |
|
10 | 644 |
|
10818 | 645 |
@Override |
36526 | 646 |
void setPaths(Iterable<? extends Path> files) { |
27118
3c8314271af7
8060043: Rename Locations.Path to Locations.SearchPath
jjg
parents:
25874
diff
changeset
|
647 |
SearchPath p; |
10818 | 648 |
if (files == null) { |
649 |
p = computePath(null); |
|
650 |
} else { |
|
14360
2a8304e421ed
6725230: Java Compilation with Jsr199 ignores Class-Path in manifest
jjg
parents:
14259
diff
changeset
|
651 |
p = createPath().addFiles(files); |
10818 | 652 |
} |
653 |
searchPath = Collections.unmodifiableCollection(p); |
|
654 |
} |
|
14360
2a8304e421ed
6725230: Java Compilation with Jsr199 ignores Class-Path in manifest
jjg
parents:
14259
diff
changeset
|
655 |
|
27118
3c8314271af7
8060043: Rename Locations.Path to Locations.SearchPath
jjg
parents:
25874
diff
changeset
|
656 |
protected SearchPath computePath(String value) { |
14360
2a8304e421ed
6725230: Java Compilation with Jsr199 ignores Class-Path in manifest
jjg
parents:
14259
diff
changeset
|
657 |
return createPath().addFiles(value); |
2a8304e421ed
6725230: Java Compilation with Jsr199 ignores Class-Path in manifest
jjg
parents:
14259
diff
changeset
|
658 |
} |
2a8304e421ed
6725230: Java Compilation with Jsr199 ignores Class-Path in manifest
jjg
parents:
14259
diff
changeset
|
659 |
|
27118
3c8314271af7
8060043: Rename Locations.Path to Locations.SearchPath
jjg
parents:
25874
diff
changeset
|
660 |
protected SearchPath createPath() { |
3c8314271af7
8060043: Rename Locations.Path to Locations.SearchPath
jjg
parents:
25874
diff
changeset
|
661 |
return new SearchPath(); |
14360
2a8304e421ed
6725230: Java Compilation with Jsr199 ignores Class-Path in manifest
jjg
parents:
14259
diff
changeset
|
662 |
} |
10 | 663 |
} |
664 |
||
10818 | 665 |
/** |
36526 | 666 |
* Subtype of SimpleLocationHandler for -classpath/CLASS_PATH. |
667 |
* If no value is given, a default is provided, based on system properties and other values. |
|
10818 | 668 |
*/ |
669 |
private class ClassPathLocationHandler extends SimpleLocationHandler { |
|
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
670 |
|
10818 | 671 |
ClassPathLocationHandler() { |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40302
diff
changeset
|
672 |
super(StandardLocation.CLASS_PATH, Option.CLASS_PATH); |
10818 | 673 |
} |
674 |
||
675 |
@Override |
|
36526 | 676 |
Collection<Path> getPaths() { |
10818 | 677 |
lazy(); |
678 |
return searchPath; |
|
679 |
} |
|
680 |
||
681 |
@Override |
|
27118
3c8314271af7
8060043: Rename Locations.Path to Locations.SearchPath
jjg
parents:
25874
diff
changeset
|
682 |
protected SearchPath computePath(String value) { |
10818 | 683 |
String cp = value; |
10 | 684 |
|
10818 | 685 |
// CLASSPATH environment variable when run from `javac'. |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
686 |
if (cp == null) { |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
687 |
cp = System.getProperty("env.class.path"); |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
688 |
} |
10818 | 689 |
|
690 |
// If invoked via a java VM (not the javac launcher), use the |
|
691 |
// platform class path |
|
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
692 |
if (cp == null && System.getProperty("application.home") == null) { |
10818 | 693 |
cp = System.getProperty("java.class.path"); |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
694 |
} |
10818 | 695 |
|
696 |
// Default to current working directory. |
|
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
697 |
if (cp == null) { |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
698 |
cp = "."; |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
699 |
} |
10818 | 700 |
|
14360
2a8304e421ed
6725230: Java Compilation with Jsr199 ignores Class-Path in manifest
jjg
parents:
14259
diff
changeset
|
701 |
return createPath().addFiles(cp); |
2a8304e421ed
6725230: Java Compilation with Jsr199 ignores Class-Path in manifest
jjg
parents:
14259
diff
changeset
|
702 |
} |
2a8304e421ed
6725230: Java Compilation with Jsr199 ignores Class-Path in manifest
jjg
parents:
14259
diff
changeset
|
703 |
|
2a8304e421ed
6725230: Java Compilation with Jsr199 ignores Class-Path in manifest
jjg
parents:
14259
diff
changeset
|
704 |
@Override |
27118
3c8314271af7
8060043: Rename Locations.Path to Locations.SearchPath
jjg
parents:
25874
diff
changeset
|
705 |
protected SearchPath createPath() { |
3c8314271af7
8060043: Rename Locations.Path to Locations.SearchPath
jjg
parents:
25874
diff
changeset
|
706 |
return new SearchPath() |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
707 |
.expandJarClassPaths(true) // Only search user jars for Class-Paths |
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
708 |
.emptyPathDefault(getPath(".")); // Empty path elt ==> current directory |
14360
2a8304e421ed
6725230: Java Compilation with Jsr199 ignores Class-Path in manifest
jjg
parents:
14259
diff
changeset
|
709 |
} |
10818 | 710 |
|
711 |
private void lazy() { |
|
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
712 |
if (searchPath == null) { |
36526 | 713 |
setPaths(null); |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
714 |
} |
10818 | 715 |
} |
10 | 716 |
} |
717 |
||
10818 | 718 |
/** |
36526 | 719 |
* Custom subtype of LocationHandler for PLATFORM_CLASS_PATH. |
720 |
* Various options are supported for different components of the |
|
721 |
* platform class path. |
|
722 |
* Setting a value with setLocation overrides all existing option values. |
|
723 |
* Setting any option overrides any value set with setLocation, and |
|
724 |
* reverts to using default values for options that have not been set. |
|
725 |
* Setting -bootclasspath or -Xbootclasspath overrides any existing |
|
726 |
* value for -Xbootclasspath/p: and -Xbootclasspath/a:. |
|
10818 | 727 |
*/ |
36526 | 728 |
private class BootClassPathLocationHandler extends BasicLocationHandler { |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
729 |
|
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
730 |
private Collection<Path> searchPath; |
22163 | 731 |
final Map<Option, String> optionValues = new EnumMap<>(Option.class); |
10818 | 732 |
|
733 |
/** |
|
27579 | 734 |
* Is the bootclasspath the default? |
10818 | 735 |
*/ |
27579 | 736 |
private boolean isDefault; |
10818 | 737 |
|
738 |
BootClassPathLocationHandler() { |
|
739 |
super(StandardLocation.PLATFORM_CLASS_PATH, |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40302
diff
changeset
|
740 |
Option.BOOT_CLASS_PATH, Option.XBOOTCLASSPATH, |
11314 | 741 |
Option.XBOOTCLASSPATH_PREPEND, |
742 |
Option.XBOOTCLASSPATH_APPEND, |
|
743 |
Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS, |
|
744 |
Option.EXTDIRS, Option.DJAVA_EXT_DIRS); |
|
10818 | 745 |
} |
746 |
||
747 |
boolean isDefault() { |
|
748 |
lazy(); |
|
27579 | 749 |
return isDefault; |
10818 | 750 |
} |
751 |
||
752 |
@Override |
|
11314 | 753 |
boolean handleOption(Option option, String value) { |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
754 |
if (!options.contains(option)) { |
10818 | 755 |
return false; |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
756 |
} |
10 | 757 |
|
10818 | 758 |
option = canonicalize(option); |
759 |
optionValues.put(option, value); |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40302
diff
changeset
|
760 |
if (option == BOOT_CLASS_PATH) { |
10818 | 761 |
optionValues.remove(XBOOTCLASSPATH_PREPEND); |
762 |
optionValues.remove(XBOOTCLASSPATH_APPEND); |
|
763 |
} |
|
764 |
searchPath = null; // reset to "uninitialized" |
|
765 |
return true; |
|
766 |
} |
|
767 |
// where |
|
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
768 |
// TODO: would be better if option aliasing was handled at a higher |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
769 |
// level |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
770 |
private Option canonicalize(Option option) { |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
771 |
switch (option) { |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
772 |
case XBOOTCLASSPATH: |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40302
diff
changeset
|
773 |
return Option.BOOT_CLASS_PATH; |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
774 |
case DJAVA_ENDORSED_DIRS: |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
775 |
return Option.ENDORSEDDIRS; |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
776 |
case DJAVA_EXT_DIRS: |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
777 |
return Option.EXTDIRS; |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
778 |
default: |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
779 |
return option; |
10818 | 780 |
} |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
781 |
} |
10 | 782 |
|
10818 | 783 |
@Override |
36526 | 784 |
Collection<Path> getPaths() { |
10 | 785 |
lazy(); |
10818 | 786 |
return searchPath; |
787 |
} |
|
788 |
||
789 |
@Override |
|
36526 | 790 |
void setPaths(Iterable<? extends Path> files) { |
10818 | 791 |
if (files == null) { |
792 |
searchPath = null; // reset to "uninitialized" |
|
793 |
} else { |
|
27579 | 794 |
isDefault = false; |
27118
3c8314271af7
8060043: Rename Locations.Path to Locations.SearchPath
jjg
parents:
25874
diff
changeset
|
795 |
SearchPath p = new SearchPath().addFiles(files, false); |
10818 | 796 |
searchPath = Collections.unmodifiableCollection(p); |
797 |
optionValues.clear(); |
|
798 |
} |
|
10 | 799 |
} |
10818 | 800 |
|
27579 | 801 |
SearchPath computePath() throws IOException { |
27118
3c8314271af7
8060043: Rename Locations.Path to Locations.SearchPath
jjg
parents:
25874
diff
changeset
|
802 |
SearchPath path = new SearchPath(); |
10818 | 803 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40302
diff
changeset
|
804 |
String bootclasspathOpt = optionValues.get(BOOT_CLASS_PATH); |
10818 | 805 |
String endorseddirsOpt = optionValues.get(ENDORSEDDIRS); |
806 |
String extdirsOpt = optionValues.get(EXTDIRS); |
|
807 |
String xbootclasspathPrependOpt = optionValues.get(XBOOTCLASSPATH_PREPEND); |
|
808 |
String xbootclasspathAppendOpt = optionValues.get(XBOOTCLASSPATH_APPEND); |
|
809 |
path.addFiles(xbootclasspathPrependOpt); |
|
810 |
||
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
811 |
if (endorseddirsOpt != null) { |
10818 | 812 |
path.addDirectories(endorseddirsOpt); |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
813 |
} else { |
10818 | 814 |
path.addDirectories(System.getProperty("java.endorsed.dirs"), false); |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
815 |
} |
10818 | 816 |
|
817 |
if (bootclasspathOpt != null) { |
|
818 |
path.addFiles(bootclasspathOpt); |
|
819 |
} else { |
|
820 |
// Standard system classes for this compiler's release. |
|
36526 | 821 |
Collection<Path> systemClasses = systemClasses(); |
27579 | 822 |
if (systemClasses != null) { |
823 |
path.addFiles(systemClasses, false); |
|
824 |
} else { |
|
825 |
// fallback to the value of sun.boot.class.path |
|
826 |
String files = System.getProperty("sun.boot.class.path"); |
|
827 |
path.addFiles(files, false); |
|
10818 | 828 |
} |
829 |
} |
|
830 |
||
831 |
path.addFiles(xbootclasspathAppendOpt); |
|
832 |
||
833 |
// Strictly speaking, standard extensions are not bootstrap |
|
834 |
// classes, but we treat them identically, so we'll pretend |
|
835 |
// that they are. |
|
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
836 |
if (extdirsOpt != null) { |
10818 | 837 |
path.addDirectories(extdirsOpt); |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
838 |
} else { |
27579 | 839 |
// Add lib/jfxrt.jar to the search path |
36526 | 840 |
Path jfxrt = javaHome.resolve("lib/jfxrt.jar"); |
27858 | 841 |
if (Files.exists(jfxrt)) { |
27579 | 842 |
path.addFile(jfxrt, false); |
843 |
} |
|
10818 | 844 |
path.addDirectories(System.getProperty("java.ext.dirs"), false); |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
845 |
} |
10818 | 846 |
|
27579 | 847 |
isDefault = |
848 |
(xbootclasspathPrependOpt == null) |
|
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
849 |
&& (bootclasspathOpt == null) |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
850 |
&& (xbootclasspathAppendOpt == null); |
10818 | 851 |
|
852 |
return path; |
|
853 |
} |
|
854 |
||
27579 | 855 |
/** |
856 |
* Return a collection of files containing system classes. |
|
857 |
* Returns {@code null} if not running on a modular image. |
|
858 |
* |
|
859 |
* @throws UncheckedIOException if an I/O errors occurs |
|
860 |
*/ |
|
36526 | 861 |
private Collection<Path> systemClasses() throws IOException { |
862 |
// Return "modules" jimage file if available |
|
863 |
if (Files.isRegularFile(thisSystemModules)) { |
|
40302
8c0d8d2c3519
8143048: Re-examine dependency on property sun.boot.class.path
jlahoda
parents:
38536
diff
changeset
|
864 |
return Collections.singleton(thisSystemModules); |
27579 | 865 |
} |
866 |
||
867 |
// Exploded module image |
|
36526 | 868 |
Path modules = javaHome.resolve("modules"); |
27579 | 869 |
if (Files.isDirectory(modules.resolve("java.base"))) { |
29053
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
28707
diff
changeset
|
870 |
try (Stream<Path> listedModules = Files.list(modules)) { |
40302
8c0d8d2c3519
8143048: Re-examine dependency on property sun.boot.class.path
jlahoda
parents:
38536
diff
changeset
|
871 |
return listedModules.collect(Collectors.toList()); |
29053
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
28707
diff
changeset
|
872 |
} |
27579 | 873 |
} |
874 |
||
875 |
// not a modular image that we know about |
|
876 |
return null; |
|
877 |
} |
|
878 |
||
10818 | 879 |
private void lazy() { |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
880 |
if (searchPath == null) { |
27579 | 881 |
try { |
10818 | 882 |
searchPath = Collections.unmodifiableCollection(computePath()); |
27579 | 883 |
} catch (IOException e) { |
884 |
// TODO: need better handling here, e.g. javac Abort? |
|
885 |
throw new UncheckedIOException(e); |
|
886 |
} |
|
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
887 |
} |
10818 | 888 |
} |
10 | 889 |
} |
890 |
||
36526 | 891 |
/** |
892 |
* A LocationHander to represent modules found from a module-oriented |
|
893 |
* location such as MODULE_SOURCE_PATH, UPGRADE_MODULE_PATH, |
|
894 |
* SYSTEM_MODULES and MODULE_PATH. |
|
895 |
* |
|
896 |
* The Location can be specified to accept overriding classes from the |
|
40762
f8883aa0053c
8160851: Remove old launcher module-related options
mchung
parents:
40513
diff
changeset
|
897 |
* {@code --patch-module <module>=<path> } parameter. |
36526 | 898 |
*/ |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
899 |
private static class ModuleLocationHandler extends LocationHandler implements Location { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
900 |
private final LocationHandler parent; |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
901 |
private final String name; |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
902 |
private final String moduleName; |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
903 |
private final boolean output; |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
904 |
Collection<Path> searchPath; |
36526 | 905 |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
906 |
ModuleLocationHandler(LocationHandler parent, String name, String moduleName, |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
907 |
Collection<Path> searchPath, boolean output) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
908 |
this.parent = parent; |
36526 | 909 |
this.name = name; |
910 |
this.moduleName = moduleName; |
|
911 |
this.searchPath = searchPath; |
|
912 |
this.output = output; |
|
913 |
} |
|
914 |
||
37848
3c8ff4204d2d
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36526
diff
changeset
|
915 |
@Override @DefinedBy(Api.COMPILER) |
36526 | 916 |
public String getName() { |
917 |
return name; |
|
918 |
} |
|
919 |
||
37848
3c8ff4204d2d
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36526
diff
changeset
|
920 |
@Override @DefinedBy(Api.COMPILER) |
36526 | 921 |
public boolean isOutputLocation() { |
922 |
return output; |
|
923 |
} |
|
924 |
||
925 |
@Override // defined by LocationHandler |
|
926 |
boolean handleOption(Option option, String value) { |
|
927 |
throw new UnsupportedOperationException(); |
|
928 |
} |
|
929 |
||
930 |
@Override // defined by LocationHandler |
|
931 |
Collection<Path> getPaths() { |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
932 |
return Collections.unmodifiableCollection(searchPath); |
36526 | 933 |
} |
934 |
||
935 |
@Override // defined by LocationHandler |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
936 |
void setPaths(Iterable<? extends Path> paths) throws IOException { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
937 |
// defer to the parent to determine if this is acceptable |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
938 |
parent.setPathsForModule(moduleName, paths); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
939 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
940 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
941 |
@Override // defined by LocationHandler |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
942 |
void setPathsForModule(String moduleName, Iterable<? extends Path> paths) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
943 |
throw new UnsupportedOperationException("not supported for " + name); |
36526 | 944 |
} |
945 |
||
946 |
@Override // defined by LocationHandler |
|
947 |
String inferModuleName() { |
|
948 |
return moduleName; |
|
949 |
} |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
950 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
951 |
@Override |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
952 |
public String toString() { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
953 |
return name; |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
954 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
955 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
956 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
957 |
/** |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
958 |
* A table of module location handlers, indexed by name and path. |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
959 |
*/ |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
960 |
private static class ModuleTable { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
961 |
private final Map<String, ModuleLocationHandler> nameMap = new LinkedHashMap<>(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
962 |
private final Map<Path, ModuleLocationHandler> pathMap = new LinkedHashMap<>(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
963 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
964 |
void add(ModuleLocationHandler h) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
965 |
nameMap.put(h.moduleName, h); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
966 |
for (Path p : h.searchPath) { |
44021
3ea5514d9fbe
8175990: Javac fails to find module-info.java if module source path contains symlinks
ksrini
parents:
44019
diff
changeset
|
967 |
pathMap.put(normalize(p), h); |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
968 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
969 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
970 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
971 |
void updatePaths(ModuleLocationHandler h) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
972 |
// use iterator, to be able to remove old entries |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
973 |
for (Iterator<Map.Entry<Path, ModuleLocationHandler>> iter = pathMap.entrySet().iterator(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
974 |
iter.hasNext(); ) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
975 |
Map.Entry<Path, ModuleLocationHandler> e = iter.next(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
976 |
if (e.getValue() == h) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
977 |
iter.remove(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
978 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
979 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
980 |
for (Path p : h.searchPath) { |
44021
3ea5514d9fbe
8175990: Javac fails to find module-info.java if module source path contains symlinks
ksrini
parents:
44019
diff
changeset
|
981 |
pathMap.put(normalize(p), h); |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
982 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
983 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
984 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
985 |
ModuleLocationHandler get(String name) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
986 |
return nameMap.get(name); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
987 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
988 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
989 |
ModuleLocationHandler get(Path path) { |
44063
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
990 |
while (path != null) { |
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
991 |
ModuleLocationHandler l = pathMap.get(path); |
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
992 |
|
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
993 |
if (l != null) |
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
994 |
return l; |
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
995 |
|
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
996 |
path = path.getParent(); |
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
997 |
} |
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
998 |
|
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
999 |
return null; |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1000 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1001 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1002 |
void clear() { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1003 |
nameMap.clear(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1004 |
pathMap.clear(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1005 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1006 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1007 |
boolean isEmpty() { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1008 |
return nameMap.isEmpty(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1009 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1010 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1011 |
Set<Location> locations() { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1012 |
return Collections.unmodifiableSet(nameMap.values().stream().collect(Collectors.toSet())); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1013 |
} |
36526 | 1014 |
} |
1015 |
||
1016 |
/** |
|
1017 |
* A LocationHandler for simple module-oriented search paths, |
|
1018 |
* like UPGRADE_MODULE_PATH and MODULE_PATH. |
|
1019 |
*/ |
|
1020 |
private class ModulePathLocationHandler extends SimpleLocationHandler { |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1021 |
private ModuleTable moduleTable; |
42414
0ae183c295a0
8162712: StandardJavaFileManager.getModuleLocation() can't find a module
jjg
parents:
42408
diff
changeset
|
1022 |
|
36526 | 1023 |
ModulePathLocationHandler(Location location, Option... options) { |
1024 |
super(location, options); |
|
1025 |
} |
|
1026 |
||
1027 |
@Override |
|
1028 |
public boolean handleOption(Option option, String value) { |
|
1029 |
if (!options.contains(option)) { |
|
1030 |
return false; |
|
1031 |
} |
|
1032 |
setPaths(value == null ? null : getPathEntries(value)); |
|
1033 |
return true; |
|
1034 |
} |
|
1035 |
||
1036 |
@Override |
|
42414
0ae183c295a0
8162712: StandardJavaFileManager.getModuleLocation() can't find a module
jjg
parents:
42408
diff
changeset
|
1037 |
public Location getLocationForModule(String moduleName) { |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1038 |
initModuleLocations(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1039 |
return moduleTable.get(moduleName); |
42414
0ae183c295a0
8162712: StandardJavaFileManager.getModuleLocation() can't find a module
jjg
parents:
42408
diff
changeset
|
1040 |
} |
0ae183c295a0
8162712: StandardJavaFileManager.getModuleLocation() can't find a module
jjg
parents:
42408
diff
changeset
|
1041 |
|
0ae183c295a0
8162712: StandardJavaFileManager.getModuleLocation() can't find a module
jjg
parents:
42408
diff
changeset
|
1042 |
@Override |
42261
bb52b5514ad5
8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents:
41861
diff
changeset
|
1043 |
Iterable<Set<Location>> listLocationsForModules() { |
36526 | 1044 |
if (searchPath == null) |
1045 |
return Collections.emptyList(); |
|
1046 |
||
42827
36468b5fa7f4
8181370: Convert anonymous inner classes into lambdas/method references
mcimadamore
parents:
42814
diff
changeset
|
1047 |
return ModulePathIterator::new; |
36526 | 1048 |
} |
1049 |
||
1050 |
@Override |
|
1051 |
void setPaths(Iterable<? extends Path> paths) { |
|
1052 |
if (paths != null) { |
|
1053 |
for (Path p: paths) { |
|
1054 |
checkValidModulePathEntry(p); |
|
1055 |
} |
|
1056 |
} |
|
1057 |
super.setPaths(paths); |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1058 |
moduleTable = null; |
36526 | 1059 |
} |
1060 |
||
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1061 |
@Override |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1062 |
void setPathsForModule(String name, Iterable<? extends Path> paths) throws IOException { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1063 |
List<Path> checkedPaths = checkPaths(paths); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1064 |
// how far should we go to validate the paths provide a module? |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1065 |
// e.g. contain module-info with the correct name? |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1066 |
initModuleLocations(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1067 |
ModuleLocationHandler l = moduleTable.get(name); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1068 |
if (l == null) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1069 |
l = new ModuleLocationHandler(this, location.getName() + "[" + name + "]", |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1070 |
name, checkedPaths, true); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1071 |
moduleTable.add(l); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1072 |
} else { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1073 |
l.searchPath = checkedPaths; |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1074 |
moduleTable.updatePaths(l); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1075 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1076 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1077 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1078 |
private List<Path> checkPaths(Iterable<? extends Path> paths) throws IOException { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1079 |
Objects.requireNonNull(paths); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1080 |
List<Path> validPaths = new ArrayList<>(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1081 |
for (Path p : paths) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1082 |
validPaths.add(checkDirectory(p)); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1083 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1084 |
return validPaths; |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1085 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1086 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1087 |
private void initModuleLocations() { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1088 |
if (moduleTable != null) { |
42414
0ae183c295a0
8162712: StandardJavaFileManager.getModuleLocation() can't find a module
jjg
parents:
42408
diff
changeset
|
1089 |
return; |
0ae183c295a0
8162712: StandardJavaFileManager.getModuleLocation() can't find a module
jjg
parents:
42408
diff
changeset
|
1090 |
} |
0ae183c295a0
8162712: StandardJavaFileManager.getModuleLocation() can't find a module
jjg
parents:
42408
diff
changeset
|
1091 |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1092 |
moduleTable = new ModuleTable(); |
42414
0ae183c295a0
8162712: StandardJavaFileManager.getModuleLocation() can't find a module
jjg
parents:
42408
diff
changeset
|
1093 |
|
0ae183c295a0
8162712: StandardJavaFileManager.getModuleLocation() can't find a module
jjg
parents:
42408
diff
changeset
|
1094 |
for (Set<Location> set : listLocationsForModules()) { |
0ae183c295a0
8162712: StandardJavaFileManager.getModuleLocation() can't find a module
jjg
parents:
42408
diff
changeset
|
1095 |
for (Location locn : set) { |
0ae183c295a0
8162712: StandardJavaFileManager.getModuleLocation() can't find a module
jjg
parents:
42408
diff
changeset
|
1096 |
if (locn instanceof ModuleLocationHandler) { |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1097 |
ModuleLocationHandler l = (ModuleLocationHandler) locn; |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1098 |
if (!moduleTable.nameMap.containsKey(l.moduleName)) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1099 |
moduleTable.add(l); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1100 |
} |
42414
0ae183c295a0
8162712: StandardJavaFileManager.getModuleLocation() can't find a module
jjg
parents:
42408
diff
changeset
|
1101 |
} |
0ae183c295a0
8162712: StandardJavaFileManager.getModuleLocation() can't find a module
jjg
parents:
42408
diff
changeset
|
1102 |
} |
0ae183c295a0
8162712: StandardJavaFileManager.getModuleLocation() can't find a module
jjg
parents:
42408
diff
changeset
|
1103 |
} |
0ae183c295a0
8162712: StandardJavaFileManager.getModuleLocation() can't find a module
jjg
parents:
42408
diff
changeset
|
1104 |
} |
0ae183c295a0
8162712: StandardJavaFileManager.getModuleLocation() can't find a module
jjg
parents:
42408
diff
changeset
|
1105 |
|
36526 | 1106 |
private void checkValidModulePathEntry(Path p) { |
43771
25ddac537bb5
8174104: Compiler does not allow non-existent module path entry
jjg
parents:
43574
diff
changeset
|
1107 |
if (!Files.exists(p)) { |
25ddac537bb5
8174104: Compiler does not allow non-existent module path entry
jjg
parents:
43574
diff
changeset
|
1108 |
// warning may be generated later |
25ddac537bb5
8174104: Compiler does not allow non-existent module path entry
jjg
parents:
43574
diff
changeset
|
1109 |
return; |
25ddac537bb5
8174104: Compiler does not allow non-existent module path entry
jjg
parents:
43574
diff
changeset
|
1110 |
} |
25ddac537bb5
8174104: Compiler does not allow non-existent module path entry
jjg
parents:
43574
diff
changeset
|
1111 |
|
36526 | 1112 |
if (Files.isDirectory(p)) { |
1113 |
// either an exploded module or a directory of modules |
|
1114 |
return; |
|
1115 |
} |
|
1116 |
||
1117 |
String name = p.getFileName().toString(); |
|
1118 |
int lastDot = name.lastIndexOf("."); |
|
1119 |
if (lastDot > 0) { |
|
1120 |
switch (name.substring(lastDot)) { |
|
1121 |
case ".jar": |
|
1122 |
case ".jmod": |
|
1123 |
return; |
|
1124 |
} |
|
1125 |
} |
|
1126 |
throw new IllegalArgumentException(p.toString()); |
|
1127 |
} |
|
1128 |
||
1129 |
class ModulePathIterator implements Iterator<Set<Location>> { |
|
1130 |
Iterator<Path> pathIter = searchPath.iterator(); |
|
1131 |
int pathIndex = 0; |
|
1132 |
Set<Location> next = null; |
|
1133 |
||
1134 |
@Override |
|
1135 |
public boolean hasNext() { |
|
1136 |
if (next != null) |
|
1137 |
return true; |
|
1138 |
||
1139 |
while (next == null) { |
|
1140 |
if (pathIter.hasNext()) { |
|
1141 |
Path path = pathIter.next(); |
|
1142 |
if (Files.isDirectory(path)) { |
|
1143 |
next = scanDirectory(path); |
|
1144 |
} else { |
|
1145 |
next = scanFile(path); |
|
1146 |
} |
|
1147 |
pathIndex++; |
|
1148 |
} else |
|
1149 |
return false; |
|
1150 |
} |
|
1151 |
return true; |
|
1152 |
} |
|
1153 |
||
1154 |
@Override |
|
1155 |
public Set<Location> next() { |
|
1156 |
hasNext(); |
|
1157 |
if (next != null) { |
|
1158 |
Set<Location> result = next; |
|
1159 |
next = null; |
|
1160 |
return result; |
|
1161 |
} |
|
1162 |
throw new NoSuchElementException(); |
|
1163 |
} |
|
1164 |
||
1165 |
private Set<Location> scanDirectory(Path path) { |
|
1166 |
Set<Path> paths = new LinkedHashSet<>(); |
|
1167 |
Path moduleInfoClass = null; |
|
1168 |
try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) { |
|
1169 |
for (Path entry: stream) { |
|
1170 |
if (entry.endsWith("module-info.class")) { |
|
1171 |
moduleInfoClass = entry; |
|
1172 |
break; // no need to continue scanning |
|
1173 |
} |
|
1174 |
paths.add(entry); |
|
1175 |
} |
|
1176 |
} catch (DirectoryIteratorException | IOException ignore) { |
|
1177 |
log.error(Errors.LocnCantReadDirectory(path)); |
|
1178 |
return Collections.emptySet(); |
|
1179 |
} |
|
1180 |
||
1181 |
if (moduleInfoClass != null) { |
|
1182 |
// It's an exploded module directly on the module path. |
|
1183 |
// We can't infer module name from the directory name, so have to |
|
1184 |
// read module-info.class. |
|
1185 |
try { |
|
1186 |
String moduleName = readModuleName(moduleInfoClass); |
|
1187 |
String name = location.getName() |
|
1188 |
+ "[" + pathIndex + ":" + moduleName + "]"; |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1189 |
ModuleLocationHandler l = new ModuleLocationHandler( |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1190 |
ModulePathLocationHandler.this, name, moduleName, |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1191 |
Collections.singletonList(path), false); |
36526 | 1192 |
return Collections.singleton(l); |
1193 |
} catch (ModuleNameReader.BadClassFile e) { |
|
1194 |
log.error(Errors.LocnBadModuleInfo(path)); |
|
1195 |
return Collections.emptySet(); |
|
1196 |
} catch (IOException e) { |
|
1197 |
log.error(Errors.LocnCantReadFile(path)); |
|
1198 |
return Collections.emptySet(); |
|
1199 |
} |
|
1200 |
} |
|
1201 |
||
1202 |
// A directory of modules |
|
1203 |
Set<Location> result = new LinkedHashSet<>(); |
|
1204 |
int index = 0; |
|
1205 |
for (Path entry : paths) { |
|
1206 |
Pair<String,Path> module = inferModuleName(entry); |
|
1207 |
if (module == null) { |
|
1208 |
// diagnostic reported if necessary; skip to next |
|
1209 |
continue; |
|
1210 |
} |
|
1211 |
String moduleName = module.fst; |
|
1212 |
Path modulePath = module.snd; |
|
1213 |
String name = location.getName() |
|
1214 |
+ "[" + pathIndex + "." + (index++) + ":" + moduleName + "]"; |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1215 |
ModuleLocationHandler l = new ModuleLocationHandler( |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1216 |
ModulePathLocationHandler.this, name, moduleName, |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1217 |
Collections.singletonList(modulePath), false); |
36526 | 1218 |
result.add(l); |
1219 |
} |
|
1220 |
return result; |
|
1221 |
} |
|
1222 |
||
1223 |
private Set<Location> scanFile(Path path) { |
|
1224 |
Pair<String,Path> module = inferModuleName(path); |
|
1225 |
if (module == null) { |
|
1226 |
// diagnostic reported if necessary |
|
1227 |
return Collections.emptySet(); |
|
1228 |
} |
|
1229 |
String moduleName = module.fst; |
|
1230 |
Path modulePath = module.snd; |
|
1231 |
String name = location.getName() |
|
1232 |
+ "[" + pathIndex + ":" + moduleName + "]"; |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1233 |
ModuleLocationHandler l = new ModuleLocationHandler( |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1234 |
ModulePathLocationHandler.this, name, moduleName, |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1235 |
Collections.singletonList(modulePath), false); |
36526 | 1236 |
return Collections.singleton(l); |
1237 |
} |
|
1238 |
||
1239 |
private Pair<String,Path> inferModuleName(Path p) { |
|
1240 |
if (Files.isDirectory(p)) { |
|
1241 |
if (Files.exists(p.resolve("module-info.class"))) { |
|
1242 |
String name = p.getFileName().toString(); |
|
1243 |
if (SourceVersion.isName(name)) |
|
1244 |
return new Pair<>(name, p); |
|
1245 |
} |
|
1246 |
return null; |
|
1247 |
} |
|
1248 |
||
38536
42569f7fe4e6
8154824: Compiler should handle java.nio.file.FileSystemNotFoundException gracefully and not abort
sadayapalam
parents:
38519
diff
changeset
|
1249 |
if (p.getFileName().toString().endsWith(".jar") && fsInfo.exists(p)) { |
43574
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
43267
diff
changeset
|
1250 |
FileSystemProvider jarFSProvider = fsInfo.getJarFSProvider(); |
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
43267
diff
changeset
|
1251 |
if (jarFSProvider == null) { |
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
43267
diff
changeset
|
1252 |
log.error(Errors.NoZipfsForArchive(p)); |
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
43267
diff
changeset
|
1253 |
return null; |
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
43267
diff
changeset
|
1254 |
} |
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
43267
diff
changeset
|
1255 |
try (FileSystem fs = jarFSProvider.newFileSystem(p, fsEnv)) { |
36526 | 1256 |
Path moduleInfoClass = fs.getPath("module-info.class"); |
1257 |
if (Files.exists(moduleInfoClass)) { |
|
1258 |
String moduleName = readModuleName(moduleInfoClass); |
|
1259 |
return new Pair<>(moduleName, p); |
|
1260 |
} |
|
1261 |
} catch (ModuleNameReader.BadClassFile e) { |
|
1262 |
log.error(Errors.LocnBadModuleInfo(p)); |
|
1263 |
return null; |
|
1264 |
} catch (IOException e) { |
|
1265 |
log.error(Errors.LocnCantReadFile(p)); |
|
1266 |
return null; |
|
1267 |
} |
|
1268 |
||
1269 |
//automatic module: |
|
1270 |
String fn = p.getFileName().toString(); |
|
1271 |
//from ModulePath.deriveModuleDescriptor: |
|
1272 |
||
1273 |
// drop .jar |
|
1274 |
String mn = fn.substring(0, fn.length()-4); |
|
1275 |
||
1276 |
// find first occurrence of -${NUMBER}. or -${NUMBER}$ |
|
1277 |
Matcher matcher = Pattern.compile("-(\\d+(\\.|$))").matcher(mn); |
|
1278 |
if (matcher.find()) { |
|
1279 |
int start = matcher.start(); |
|
1280 |
||
1281 |
mn = mn.substring(0, start); |
|
1282 |
} |
|
1283 |
||
1284 |
// finally clean up the module name |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41861
diff
changeset
|
1285 |
mn = mn.replaceAll("(\\.|\\d)*$", "") // remove trailing version |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41861
diff
changeset
|
1286 |
.replaceAll("[^A-Za-z0-9]", ".") // replace non-alphanumeric |
36526 | 1287 |
.replaceAll("(\\.)(\\1)+", ".") // collapse repeating dots |
1288 |
.replaceAll("^\\.", "") // drop leading dots |
|
1289 |
.replaceAll("\\.$", ""); // drop trailing dots |
|
1290 |
||
1291 |
||
1292 |
if (!mn.isEmpty()) { |
|
1293 |
return new Pair<>(mn, p); |
|
1294 |
} |
|
1295 |
||
1296 |
log.error(Errors.LocnCantGetModuleNameForJar(p)); |
|
1297 |
return null; |
|
1298 |
} |
|
1299 |
||
1300 |
if (p.getFileName().toString().endsWith(".jmod")) { |
|
1301 |
try { |
|
41440 | 1302 |
// check if the JMOD file is valid |
1303 |
JDK9Wrappers.JmodFile.checkMagic(p); |
|
1304 |
||
1305 |
// No JMOD file system. Use JarFileSystem to |
|
1306 |
// workaround for now |
|
36526 | 1307 |
FileSystem fs = fileSystems.get(p); |
1308 |
if (fs == null) { |
|
43574
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
43267
diff
changeset
|
1309 |
FileSystemProvider jarFSProvider = fsInfo.getJarFSProvider(); |
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
43267
diff
changeset
|
1310 |
if (jarFSProvider == null) { |
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
43267
diff
changeset
|
1311 |
log.error(Errors.LocnCantReadFile(p)); |
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
43267
diff
changeset
|
1312 |
return null; |
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
43267
diff
changeset
|
1313 |
} |
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
43267
diff
changeset
|
1314 |
fs = jarFSProvider.newFileSystem(p, Collections.emptyMap()); |
36526 | 1315 |
try { |
1316 |
Path moduleInfoClass = fs.getPath("classes/module-info.class"); |
|
1317 |
String moduleName = readModuleName(moduleInfoClass); |
|
1318 |
Path modulePath = fs.getPath("classes"); |
|
1319 |
fileSystems.put(p, fs); |
|
1320 |
closeables.add(fs); |
|
1321 |
fs = null; // prevent fs being closed in the finally clause |
|
1322 |
return new Pair<>(moduleName, modulePath); |
|
1323 |
} finally { |
|
1324 |
if (fs != null) |
|
1325 |
fs.close(); |
|
1326 |
} |
|
1327 |
} |
|
1328 |
} catch (ModuleNameReader.BadClassFile e) { |
|
1329 |
log.error(Errors.LocnBadModuleInfo(p)); |
|
43574
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
43267
diff
changeset
|
1330 |
} catch (IOException e) { |
36526 | 1331 |
log.error(Errors.LocnCantReadFile(p)); |
1332 |
return null; |
|
1333 |
} |
|
1334 |
} |
|
1335 |
||
38519 | 1336 |
if (warn && false) { // temp disable, when enabled, massage examples.not-yet.txt suitably. |
36526 | 1337 |
log.warning(Warnings.LocnUnknownFileOnModulePath(p)); |
1338 |
} |
|
1339 |
return null; |
|
1340 |
} |
|
1341 |
||
1342 |
private String readModuleName(Path path) throws IOException, ModuleNameReader.BadClassFile { |
|
1343 |
if (moduleNameReader == null) |
|
1344 |
moduleNameReader = new ModuleNameReader(); |
|
1345 |
return moduleNameReader.readModuleName(path); |
|
1346 |
} |
|
1347 |
} |
|
1348 |
||
1349 |
} |
|
1350 |
||
1351 |
private class ModuleSourcePathLocationHandler extends BasicLocationHandler { |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1352 |
private ModuleTable moduleTable; |
36526 | 1353 |
|
1354 |
ModuleSourcePathLocationHandler() { |
|
1355 |
super(StandardLocation.MODULE_SOURCE_PATH, |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40302
diff
changeset
|
1356 |
Option.MODULE_SOURCE_PATH); |
36526 | 1357 |
} |
1358 |
||
1359 |
@Override |
|
1360 |
boolean handleOption(Option option, String value) { |
|
1361 |
init(value); |
|
1362 |
return true; |
|
1363 |
} |
|
1364 |
||
1365 |
void init(String value) { |
|
1366 |
Collection<String> segments = new ArrayList<>(); |
|
1367 |
for (String s: value.split(File.pathSeparator)) { |
|
1368 |
expandBraces(s, segments); |
|
1369 |
} |
|
1370 |
||
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1371 |
Map<String, List<Path>> map = new LinkedHashMap<>(); |
36526 | 1372 |
final String MARKER = "*"; |
1373 |
for (String seg: segments) { |
|
1374 |
int markStart = seg.indexOf(MARKER); |
|
1375 |
if (markStart == -1) { |
|
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
1376 |
add(map, getPath(seg), null); |
36526 | 1377 |
} else { |
1378 |
if (markStart == 0 || !isSeparator(seg.charAt(markStart - 1))) { |
|
1379 |
throw new IllegalArgumentException("illegal use of " + MARKER + " in " + seg); |
|
1380 |
} |
|
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
1381 |
Path prefix = getPath(seg.substring(0, markStart - 1)); |
36526 | 1382 |
Path suffix; |
1383 |
int markEnd = markStart + MARKER.length(); |
|
1384 |
if (markEnd == seg.length()) { |
|
1385 |
suffix = null; |
|
1386 |
} else if (!isSeparator(seg.charAt(markEnd)) |
|
1387 |
|| seg.indexOf(MARKER, markEnd) != -1) { |
|
1388 |
throw new IllegalArgumentException("illegal use of " + MARKER + " in " + seg); |
|
1389 |
} else { |
|
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
1390 |
suffix = getPath(seg.substring(markEnd + 1)); |
36526 | 1391 |
} |
1392 |
add(map, prefix, suffix); |
|
1393 |
} |
|
1394 |
} |
|
1395 |
||
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1396 |
moduleTable = new ModuleTable(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1397 |
map.forEach((modName, modPath) -> { |
44063
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1398 |
boolean hasModuleInfo = modPath.stream().anyMatch(checkModuleInfo); |
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1399 |
if (hasModuleInfo) { |
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1400 |
String locnName = location.getName() + "[" + modName + "]"; |
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1401 |
ModuleLocationHandler l = new ModuleLocationHandler(this, locnName, modName, |
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1402 |
modPath, false); |
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1403 |
moduleTable.add(l); |
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1404 |
} |
36526 | 1405 |
}); |
1406 |
} |
|
44063
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1407 |
//where: |
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1408 |
private final Predicate<Path> checkModuleInfo = |
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1409 |
p -> Files.exists(p.resolve("module-info.java")); |
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1410 |
|
36526 | 1411 |
|
1412 |
private boolean isSeparator(char ch) { |
|
1413 |
// allow both separators on Windows |
|
1414 |
return (ch == File.separatorChar) || (ch == '/'); |
|
1415 |
} |
|
1416 |
||
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1417 |
void add(Map<String, List<Path>> map, Path prefix, Path suffix) { |
36526 | 1418 |
if (!Files.isDirectory(prefix)) { |
1419 |
if (warn) { |
|
1420 |
String key = Files.exists(prefix) |
|
1421 |
? "dir.path.element.not.directory" |
|
1422 |
: "dir.path.element.not.found"; |
|
1423 |
log.warning(Lint.LintCategory.PATH, key, prefix); |
|
1424 |
} |
|
1425 |
return; |
|
1426 |
} |
|
1427 |
try (DirectoryStream<Path> stream = Files.newDirectoryStream(prefix, path -> Files.isDirectory(path))) { |
|
1428 |
for (Path entry: stream) { |
|
1429 |
Path path = (suffix == null) ? entry : entry.resolve(suffix); |
|
1430 |
if (Files.isDirectory(path)) { |
|
1431 |
String name = entry.getFileName().toString(); |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1432 |
List<Path> paths = map.get(name); |
36526 | 1433 |
if (paths == null) |
1434 |
map.put(name, paths = new ArrayList<>()); |
|
1435 |
paths.add(path); |
|
1436 |
} |
|
1437 |
} |
|
1438 |
} catch (IOException e) { |
|
1439 |
// TODO? What to do? |
|
1440 |
System.err.println(e); |
|
1441 |
} |
|
1442 |
} |
|
1443 |
||
1444 |
private void expandBraces(String value, Collection<String> results) { |
|
1445 |
int depth = 0; |
|
1446 |
int start = -1; |
|
1447 |
String prefix = null; |
|
1448 |
String suffix = null; |
|
1449 |
for (int i = 0; i < value.length(); i++) { |
|
1450 |
switch (value.charAt(i)) { |
|
1451 |
case '{': |
|
1452 |
depth++; |
|
1453 |
if (depth == 1) { |
|
1454 |
prefix = value.substring(0, i); |
|
1455 |
suffix = value.substring(getMatchingBrace(value, i) + 1); |
|
1456 |
start = i + 1; |
|
1457 |
} |
|
1458 |
break; |
|
1459 |
||
1460 |
case ',': |
|
1461 |
if (depth == 1) { |
|
1462 |
String elem = value.substring(start, i); |
|
1463 |
expandBraces(prefix + elem + suffix, results); |
|
1464 |
start = i + 1; |
|
1465 |
} |
|
1466 |
break; |
|
1467 |
||
1468 |
case '}': |
|
1469 |
switch (depth) { |
|
1470 |
case 0: |
|
1471 |
throw new IllegalArgumentException("mismatched braces"); |
|
1472 |
||
1473 |
case 1: |
|
1474 |
String elem = value.substring(start, i); |
|
1475 |
expandBraces(prefix + elem + suffix, results); |
|
1476 |
return; |
|
1477 |
||
1478 |
default: |
|
1479 |
depth--; |
|
1480 |
} |
|
1481 |
break; |
|
1482 |
} |
|
1483 |
} |
|
1484 |
if (depth > 0) |
|
1485 |
throw new IllegalArgumentException("mismatched braces"); |
|
1486 |
results.add(value); |
|
1487 |
} |
|
1488 |
||
1489 |
int getMatchingBrace(String value, int offset) { |
|
1490 |
int depth = 1; |
|
1491 |
for (int i = offset + 1; i < value.length(); i++) { |
|
1492 |
switch (value.charAt(i)) { |
|
1493 |
case '{': |
|
1494 |
depth++; |
|
1495 |
break; |
|
1496 |
||
1497 |
case '}': |
|
1498 |
if (--depth == 0) |
|
1499 |
return i; |
|
1500 |
break; |
|
1501 |
} |
|
1502 |
} |
|
1503 |
throw new IllegalArgumentException("mismatched braces"); |
|
1504 |
} |
|
1505 |
||
1506 |
@Override |
|
1507 |
boolean isSet() { |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1508 |
return (moduleTable != null); |
36526 | 1509 |
} |
1510 |
||
1511 |
@Override |
|
1512 |
Collection<Path> getPaths() { |
|
1513 |
throw new UnsupportedOperationException(); |
|
1514 |
} |
|
1515 |
||
1516 |
@Override |
|
1517 |
void setPaths(Iterable<? extends Path> files) throws IOException { |
|
1518 |
throw new UnsupportedOperationException(); |
|
1519 |
} |
|
1520 |
||
1521 |
@Override |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1522 |
void setPathsForModule(String name, Iterable<? extends Path> paths) throws IOException { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1523 |
List<Path> validPaths = checkPaths(paths); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1524 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1525 |
if (moduleTable == null) |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1526 |
moduleTable = new ModuleTable(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1527 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1528 |
ModuleLocationHandler l = moduleTable.get(name); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1529 |
if (l == null) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1530 |
l = new ModuleLocationHandler(this, |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1531 |
location.getName() + "[" + name + "]", |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1532 |
name, |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1533 |
validPaths, |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1534 |
true); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1535 |
moduleTable.add(l); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1536 |
} else { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1537 |
l.searchPath = validPaths; |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1538 |
moduleTable.updatePaths(l); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1539 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1540 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1541 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1542 |
private List<Path> checkPaths(Iterable<? extends Path> paths) throws IOException { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1543 |
Objects.requireNonNull(paths); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1544 |
List<Path> validPaths = new ArrayList<>(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1545 |
for (Path p : paths) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1546 |
validPaths.add(checkDirectory(p)); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1547 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1548 |
return validPaths; |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1549 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1550 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1551 |
@Override |
42261
bb52b5514ad5
8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents:
41861
diff
changeset
|
1552 |
Location getLocationForModule(String name) { |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1553 |
return (moduleTable == null) ? null : moduleTable.get(name); |
36526 | 1554 |
} |
1555 |
||
1556 |
@Override |
|
44063
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1557 |
Location getLocationForModule(Path file) { |
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1558 |
return (moduleTable == null) ? null : moduleTable.get(file); |
36526 | 1559 |
} |
1560 |
||
1561 |
@Override |
|
42261
bb52b5514ad5
8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents:
41861
diff
changeset
|
1562 |
Iterable<Set<Location>> listLocationsForModules() { |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1563 |
if (moduleTable == null) |
36526 | 1564 |
return Collections.emptySet(); |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1565 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1566 |
return Collections.singleton(moduleTable.locations()); |
36526 | 1567 |
} |
1568 |
||
1569 |
} |
|
1570 |
||
1571 |
private class SystemModulesLocationHandler extends BasicLocationHandler { |
|
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
1572 |
private Path systemJavaHome; |
36526 | 1573 |
private Path modules; |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1574 |
private ModuleTable moduleTable; |
36526 | 1575 |
|
1576 |
SystemModulesLocationHandler() { |
|
1577 |
super(StandardLocation.SYSTEM_MODULES, Option.SYSTEM); |
|
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
1578 |
systemJavaHome = Locations.javaHome; |
36526 | 1579 |
} |
1580 |
||
1581 |
@Override |
|
1582 |
boolean handleOption(Option option, String value) { |
|
1583 |
if (!options.contains(option)) { |
|
1584 |
return false; |
|
1585 |
} |
|
1586 |
||
1587 |
if (value == null) { |
|
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
1588 |
systemJavaHome = Locations.javaHome; |
36526 | 1589 |
} else if (value.equals("none")) { |
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
1590 |
systemJavaHome = null; |
36526 | 1591 |
} else { |
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
1592 |
update(getPath(value)); |
36526 | 1593 |
} |
1594 |
||
1595 |
modules = null; |
|
1596 |
return true; |
|
1597 |
} |
|
1598 |
||
1599 |
@Override |
|
1600 |
Collection<Path> getPaths() { |
|
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
1601 |
return (systemJavaHome == null) ? null : Collections.singleton(systemJavaHome); |
36526 | 1602 |
} |
1603 |
||
1604 |
@Override |
|
1605 |
void setPaths(Iterable<? extends Path> files) throws IOException { |
|
1606 |
if (files == null) { |
|
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
1607 |
systemJavaHome = null; |
36526 | 1608 |
} else { |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1609 |
Path dir = checkSingletonDirectory(files); |
36526 | 1610 |
update(dir); |
1611 |
} |
|
1612 |
} |
|
1613 |
||
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1614 |
@Override |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1615 |
void setPathsForModule(String name, Iterable<? extends Path> paths) throws IOException { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1616 |
List<Path> checkedPaths = checkPaths(paths); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1617 |
initSystemModules(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1618 |
ModuleLocationHandler l = moduleTable.get(name); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1619 |
if (l == null) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1620 |
l = new ModuleLocationHandler(this, |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1621 |
location.getName() + "[" + name + "]", |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1622 |
name, |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1623 |
checkedPaths, |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1624 |
true); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1625 |
moduleTable.add(l); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1626 |
} else { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1627 |
l.searchPath = checkedPaths; |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1628 |
moduleTable.updatePaths(l); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1629 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1630 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1631 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1632 |
private List<Path> checkPaths(Iterable<? extends Path> paths) throws IOException { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1633 |
Objects.requireNonNull(paths); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1634 |
List<Path> validPaths = new ArrayList<>(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1635 |
for (Path p : paths) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1636 |
validPaths.add(checkDirectory(p)); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1637 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1638 |
return validPaths; |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1639 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1640 |
|
36526 | 1641 |
private void update(Path p) { |
42404
c4a34c2a656c
8169816: Move src.zip and jrt-fs.jar under the lib directory
mchung
parents:
42261
diff
changeset
|
1642 |
if (!isCurrentPlatform(p) && !Files.exists(p.resolve("lib").resolve("jrt-fs.jar")) && |
c4a34c2a656c
8169816: Move src.zip and jrt-fs.jar under the lib directory
mchung
parents:
42261
diff
changeset
|
1643 |
!Files.exists(systemJavaHome.resolve("modules"))) |
36526 | 1644 |
throw new IllegalArgumentException(p.toString()); |
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
1645 |
systemJavaHome = p; |
36526 | 1646 |
modules = null; |
1647 |
} |
|
1648 |
||
1649 |
private boolean isCurrentPlatform(Path p) { |
|
1650 |
try { |
|
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
1651 |
return Files.isSameFile(p, Locations.javaHome); |
36526 | 1652 |
} catch (IOException ex) { |
1653 |
throw new IllegalArgumentException(p.toString(), ex); |
|
1654 |
} |
|
1655 |
} |
|
1656 |
||
1657 |
@Override |
|
42261
bb52b5514ad5
8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents:
41861
diff
changeset
|
1658 |
Location getLocationForModule(String name) throws IOException { |
36526 | 1659 |
initSystemModules(); |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1660 |
return moduleTable.get(name); |
36526 | 1661 |
} |
1662 |
||
1663 |
@Override |
|
44063
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1664 |
Location getLocationForModule(Path file) throws IOException { |
43772
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1665 |
initSystemModules(); |
44063
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1666 |
return moduleTable.get(file); |
43772
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1667 |
} |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1668 |
|
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1669 |
@Override |
42261
bb52b5514ad5
8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents:
41861
diff
changeset
|
1670 |
Iterable<Set<Location>> listLocationsForModules() throws IOException { |
36526 | 1671 |
initSystemModules(); |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1672 |
return Collections.singleton(moduleTable.locations()); |
36526 | 1673 |
} |
1674 |
||
1675 |
private void initSystemModules() throws IOException { |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1676 |
if (moduleTable != null) |
36526 | 1677 |
return; |
1678 |
||
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
1679 |
if (systemJavaHome == null) { |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1680 |
moduleTable = new ModuleTable(); |
36526 | 1681 |
return; |
1682 |
} |
|
1683 |
||
1684 |
if (modules == null) { |
|
1685 |
try { |
|
1686 |
URI jrtURI = URI.create("jrt:/"); |
|
1687 |
FileSystem jrtfs; |
|
1688 |
||
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
1689 |
if (isCurrentPlatform(systemJavaHome)) { |
36526 | 1690 |
jrtfs = FileSystems.getFileSystem(jrtURI); |
1691 |
} else { |
|
1692 |
try { |
|
1693 |
Map<String, String> attrMap = |
|
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
1694 |
Collections.singletonMap("java.home", systemJavaHome.toString()); |
36526 | 1695 |
jrtfs = FileSystems.newFileSystem(jrtURI, attrMap); |
1696 |
} catch (ProviderNotFoundException ex) { |
|
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
1697 |
URL javaHomeURL = systemJavaHome.resolve("jrt-fs.jar").toUri().toURL(); |
36526 | 1698 |
ClassLoader currentLoader = Locations.class.getClassLoader(); |
1699 |
URLClassLoader fsLoader = |
|
1700 |
new URLClassLoader(new URL[] {javaHomeURL}, currentLoader); |
|
1701 |
||
1702 |
jrtfs = FileSystems.newFileSystem(jrtURI, Collections.emptyMap(), fsLoader); |
|
1703 |
||
1704 |
closeables.add(fsLoader); |
|
1705 |
} |
|
1706 |
||
1707 |
closeables.add(jrtfs); |
|
1708 |
} |
|
1709 |
||
1710 |
modules = jrtfs.getPath("/modules"); |
|
1711 |
} catch (FileSystemNotFoundException | ProviderNotFoundException e) { |
|
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
37848
diff
changeset
|
1712 |
modules = systemJavaHome.resolve("modules"); |
36526 | 1713 |
if (!Files.exists(modules)) |
1714 |
throw new IOException("can't find system classes", e); |
|
1715 |
} |
|
1716 |
} |
|
1717 |
||
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1718 |
moduleTable = new ModuleTable(); |
36526 | 1719 |
try (DirectoryStream<Path> stream = Files.newDirectoryStream(modules, Files::isDirectory)) { |
1720 |
for (Path entry : stream) { |
|
1721 |
String moduleName = entry.getFileName().toString(); |
|
1722 |
String name = location.getName() + "[" + moduleName + "]"; |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1723 |
ModuleLocationHandler h = new ModuleLocationHandler(this, |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1724 |
name, moduleName, Collections.singletonList(entry), false); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1725 |
moduleTable.add(h); |
36526 | 1726 |
} |
1727 |
} |
|
1728 |
} |
|
1729 |
} |
|
1730 |
||
43772
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1731 |
private class PatchModulesLocationHandler extends BasicLocationHandler { |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1732 |
private final ModuleTable moduleTable = new ModuleTable(); |
43772
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1733 |
|
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1734 |
PatchModulesLocationHandler() { |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1735 |
super(StandardLocation.PATCH_MODULE_PATH, Option.PATCH_MODULE); |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1736 |
} |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1737 |
|
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1738 |
@Override |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1739 |
boolean handleOption(Option option, String value) { |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1740 |
if (!options.contains(option)) { |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1741 |
return false; |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1742 |
} |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1743 |
|
44063
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1744 |
moduleTable.clear(); |
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1745 |
|
43772
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1746 |
// Allow an extended syntax for --patch-module consisting of a series |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1747 |
// of values separated by NULL characters. This is to facilitate |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1748 |
// supporting deferred file manager options on the command line. |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1749 |
// See Option.PATCH_MODULE for the code that composes these multiple |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1750 |
// values. |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1751 |
for (String v : value.split("\0")) { |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1752 |
int eq = v.indexOf('='); |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1753 |
if (eq > 0) { |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1754 |
String moduleName = v.substring(0, eq); |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1755 |
SearchPath mPatchPath = new SearchPath() |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1756 |
.addFiles(v.substring(eq + 1)); |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1757 |
String name = location.getName() + "[" + moduleName + "]"; |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1758 |
ModuleLocationHandler h = new ModuleLocationHandler(this, name, |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1759 |
moduleName, mPatchPath, false); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1760 |
moduleTable.add(h); |
43772
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1761 |
} else { |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1762 |
// Should not be able to get here; |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1763 |
// this should be caught and handled in Option.PATCH_MODULE |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1764 |
log.error(Errors.LocnInvalidArgForXpatch(value)); |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1765 |
} |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1766 |
} |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1767 |
|
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1768 |
return true; |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1769 |
} |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1770 |
|
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1771 |
@Override |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1772 |
boolean isSet() { |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1773 |
return !moduleTable.isEmpty(); |
43772
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1774 |
} |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1775 |
|
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1776 |
@Override |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1777 |
Collection<Path> getPaths() { |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1778 |
throw new UnsupportedOperationException(); |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1779 |
} |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1780 |
|
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1781 |
@Override |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1782 |
void setPaths(Iterable<? extends Path> files) throws IOException { |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1783 |
throw new UnsupportedOperationException(); |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1784 |
} |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1785 |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1786 |
@Override // defined by LocationHandler |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1787 |
void setPathsForModule(String moduleName, Iterable<? extends Path> files) throws IOException { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1788 |
throw new UnsupportedOperationException(); // not yet |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1789 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1790 |
|
43772
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1791 |
@Override |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1792 |
Location getLocationForModule(String name) throws IOException { |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1793 |
return moduleTable.get(name); |
43772
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1794 |
} |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1795 |
|
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1796 |
@Override |
44063
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1797 |
Location getLocationForModule(Path file) throws IOException { |
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1798 |
return moduleTable.get(file); |
43772
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1799 |
} |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1800 |
|
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1801 |
@Override |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1802 |
Iterable<Set<Location>> listLocationsForModules() throws IOException { |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1803 |
return Collections.singleton(moduleTable.locations()); |
43772
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1804 |
} |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1805 |
} |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1806 |
|
10818 | 1807 |
Map<Location, LocationHandler> handlersForLocation; |
11314 | 1808 |
Map<Option, LocationHandler> handlersForOption; |
10818 | 1809 |
|
1810 |
void initHandlers() { |
|
22163 | 1811 |
handlersForLocation = new HashMap<>(); |
1812 |
handlersForOption = new EnumMap<>(Option.class); |
|
10818 | 1813 |
|
36526 | 1814 |
BasicLocationHandler[] handlers = { |
10818 | 1815 |
new BootClassPathLocationHandler(), |
1816 |
new ClassPathLocationHandler(), |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40302
diff
changeset
|
1817 |
new SimpleLocationHandler(StandardLocation.SOURCE_PATH, Option.SOURCE_PATH), |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40302
diff
changeset
|
1818 |
new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_PATH, Option.PROCESSOR_PATH), |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40302
diff
changeset
|
1819 |
new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_MODULE_PATH, Option.PROCESSOR_MODULE_PATH), |
36526 | 1820 |
new OutputLocationHandler(StandardLocation.CLASS_OUTPUT, Option.D), |
1821 |
new OutputLocationHandler(StandardLocation.SOURCE_OUTPUT, Option.S), |
|
1822 |
new OutputLocationHandler(StandardLocation.NATIVE_HEADER_OUTPUT, Option.H), |
|
1823 |
new ModuleSourcePathLocationHandler(), |
|
43772
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1824 |
new PatchModulesLocationHandler(), |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40302
diff
changeset
|
1825 |
new ModulePathLocationHandler(StandardLocation.UPGRADE_MODULE_PATH, Option.UPGRADE_MODULE_PATH), |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40302
diff
changeset
|
1826 |
new ModulePathLocationHandler(StandardLocation.MODULE_PATH, Option.MODULE_PATH), |
36526 | 1827 |
new SystemModulesLocationHandler(), |
10818 | 1828 |
}; |
10 | 1829 |
|
36526 | 1830 |
for (BasicLocationHandler h : handlers) { |
10818 | 1831 |
handlersForLocation.put(h.location, h); |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
1832 |
for (Option o : h.options) { |
10818 | 1833 |
handlersForOption.put(o, h); |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
1834 |
} |
10 | 1835 |
} |
10818 | 1836 |
} |
1837 |
||
29780
8f8e54a1fa20
8076420: Consolidate javac file handling in javac.file package
jjg
parents:
29291
diff
changeset
|
1838 |
boolean handleOption(Option option, String value) { |
43772
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1839 |
LocationHandler h = handlersForOption.get(option); |
4e5350b7be75
8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents:
43771
diff
changeset
|
1840 |
return (h == null ? false : h.handleOption(option, value)); |
36526 | 1841 |
} |
1842 |
||
1843 |
boolean hasLocation(Location location) { |
|
1844 |
LocationHandler h = getHandler(location); |
|
1845 |
return (h == null ? false : h.isSet()); |
|
10818 | 1846 |
} |
1847 |
||
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
1848 |
Collection<Path> getLocation(Location location) { |
10818 | 1849 |
LocationHandler h = getHandler(location); |
36526 | 1850 |
return (h == null ? null : h.getPaths()); |
10 | 1851 |
} |
1852 |
||
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
1853 |
Path getOutputLocation(Location location) { |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
1854 |
if (!location.isOutputLocation()) { |
10818 | 1855 |
throw new IllegalArgumentException(); |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
1856 |
} |
10818 | 1857 |
LocationHandler h = getHandler(location); |
1858 |
return ((OutputLocationHandler) h).outputDir; |
|
1859 |
} |
|
10 | 1860 |
|
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
1861 |
void setLocation(Location location, Iterable<? extends Path> files) throws IOException { |
10818 | 1862 |
LocationHandler h = getHandler(location); |
1863 |
if (h == null) { |
|
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
1864 |
if (location.isOutputLocation()) { |
10818 | 1865 |
h = new OutputLocationHandler(location); |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
1866 |
} else { |
10818 | 1867 |
h = new SimpleLocationHandler(location); |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
1868 |
} |
10818 | 1869 |
handlersForLocation.put(location, h); |
1870 |
} |
|
36526 | 1871 |
h.setPaths(files); |
1872 |
} |
|
1873 |
||
42261
bb52b5514ad5
8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents:
41861
diff
changeset
|
1874 |
Location getLocationForModule(Location location, String name) throws IOException { |
36526 | 1875 |
LocationHandler h = getHandler(location); |
42261
bb52b5514ad5
8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents:
41861
diff
changeset
|
1876 |
return (h == null ? null : h.getLocationForModule(name)); |
36526 | 1877 |
} |
1878 |
||
44063
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1879 |
Location getLocationForModule(Location location, Path file) throws IOException { |
36526 | 1880 |
LocationHandler h = getHandler(location); |
44063
5f0cf4126949
8175560: Drop String pkgName from javax.tools.JavaFileManager.getLocationForModule(Location location, JavaFileObject fo, String pkgName)
jlahoda
parents:
44021
diff
changeset
|
1881 |
return (h == null ? null : h.getLocationForModule(file)); |
36526 | 1882 |
} |
1883 |
||
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1884 |
void setLocationForModule(Location location, String moduleName, |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1885 |
Iterable<? extends Path> files) throws IOException { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1886 |
LocationHandler h = getHandler(location); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1887 |
if (h == null) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1888 |
if (location.isOutputLocation()) { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1889 |
h = new OutputLocationHandler(location); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1890 |
} else { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1891 |
h = new ModulePathLocationHandler(location); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1892 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1893 |
handlersForLocation.put(location, h); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1894 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1895 |
h.setPathsForModule(moduleName, files); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1896 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
43772
diff
changeset
|
1897 |
|
36526 | 1898 |
String inferModuleName(Location location) { |
1899 |
LocationHandler h = getHandler(location); |
|
1900 |
return (h == null ? null : h.inferModuleName()); |
|
1901 |
} |
|
1902 |
||
42261
bb52b5514ad5
8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents:
41861
diff
changeset
|
1903 |
Iterable<Set<Location>> listLocationsForModules(Location location) throws IOException { |
36526 | 1904 |
LocationHandler h = getHandler(location); |
42261
bb52b5514ad5
8163190: Clarify JavaFileManager use of \"module location\"
jjg
parents:
41861
diff
changeset
|
1905 |
return (h == null ? null : h.listLocationsForModules()); |
10818 | 1906 |
} |
1907 |
||
1908 |
protected LocationHandler getHandler(Location location) { |
|
29291
076c277565f7
8073550: java* tools: replace obj.getClass hacks with Assert.checkNonNull or Objects.requireNonNull
mcimadamore
parents:
29053
diff
changeset
|
1909 |
Objects.requireNonNull(location); |
36526 | 1910 |
return (location instanceof LocationHandler) |
1911 |
? (LocationHandler) location |
|
1912 |
: handlersForLocation.get(location); |
|
10818 | 1913 |
} |
1914 |
||
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
1915 |
/** |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
1916 |
* Is this the name of an archive file? |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
1917 |
*/ |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
1918 |
private boolean isArchive(Path file) { |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
1919 |
String n = StringUtils.toLowerCase(file.getFileName().toString()); |
1208 | 1920 |
return fsInfo.isFile(file) |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
1921 |
&& (n.endsWith(".jar") || n.endsWith(".zip")); |
10 | 1922 |
} |
4937
2fc03fb01efa
6927061: Refactor apt implemenation to use code from JSR 269
darcy
parents:
4548
diff
changeset
|
1923 |
|
36526 | 1924 |
static Path normalize(Path p) { |
1925 |
try { |
|
1926 |
return p.toRealPath(); |
|
1927 |
} catch (IOException e) { |
|
1928 |
return p.toAbsolutePath().normalize(); |
|
1929 |
} |
|
1930 |
} |
|
10 | 1931 |
} |