265 } |
265 } |
266 |
266 |
267 private List<ModuleSymbol> scanModulePath(ModuleSymbol toFind) { |
267 private List<ModuleSymbol> scanModulePath(ModuleSymbol toFind) { |
268 ListBuffer<ModuleSymbol> results = new ListBuffer<>(); |
268 ListBuffer<ModuleSymbol> results = new ListBuffer<>(); |
269 Map<Name, Location> namesInSet = new HashMap<>(); |
269 Map<Name, Location> namesInSet = new HashMap<>(); |
|
270 boolean multiModuleMode = fileManager.hasLocation(StandardLocation.MODULE_SOURCE_PATH); |
270 while (moduleLocationIterator.hasNext()) { |
271 while (moduleLocationIterator.hasNext()) { |
271 Set<Location> locns = (moduleLocationIterator.next()); |
272 Set<Location> locns = (moduleLocationIterator.next()); |
272 namesInSet.clear(); |
273 namesInSet.clear(); |
273 for (Location l: locns) { |
274 for (Location l: locns) { |
274 try { |
275 try { |
277 ModuleSymbol msym = syms.enterModule(n); |
278 ModuleSymbol msym = syms.enterModule(n); |
278 if (msym.sourceLocation != null || msym.classLocation != null) { |
279 if (msym.sourceLocation != null || msym.classLocation != null) { |
279 // module has already been found, so ignore this instance |
280 // module has already been found, so ignore this instance |
280 continue; |
281 continue; |
281 } |
282 } |
|
283 if (fileManager.hasLocation(StandardLocation.PATCH_MODULE_PATH) && |
|
284 msym.patchLocation == null) { |
|
285 msym.patchLocation = |
|
286 fileManager.getLocationForModule(StandardLocation.PATCH_MODULE_PATH, |
|
287 msym.name.toString()); |
|
288 checkModuleInfoOnLocation(msym.patchLocation, Kind.CLASS, Kind.SOURCE); |
|
289 if (msym.patchLocation != null && |
|
290 multiModuleMode && |
|
291 fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) { |
|
292 msym.patchOutputLocation = |
|
293 fileManager.getLocationForModule(StandardLocation.CLASS_OUTPUT, |
|
294 msym.name.toString()); |
|
295 checkModuleInfoOnLocation(msym.patchOutputLocation, Kind.CLASS); |
|
296 } |
|
297 } |
282 if (moduleLocationIterator.outer == StandardLocation.MODULE_SOURCE_PATH) { |
298 if (moduleLocationIterator.outer == StandardLocation.MODULE_SOURCE_PATH) { |
283 msym.sourceLocation = l; |
299 if (msym.patchLocation == null) { |
284 if (fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) { |
300 msym.sourceLocation = l; |
285 msym.classLocation = fileManager.getLocationForModule(StandardLocation.CLASS_OUTPUT, msym.name.toString()); |
301 if (fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) { |
|
302 msym.classLocation = |
|
303 fileManager.getLocationForModule(StandardLocation.CLASS_OUTPUT, |
|
304 msym.name.toString()); |
|
305 } |
286 } |
306 } |
287 } else { |
307 } else { |
288 msym.classLocation = l; |
308 msym.classLocation = l; |
289 } |
309 } |
290 if (moduleLocationIterator.outer == StandardLocation.SYSTEM_MODULES || |
310 if (moduleLocationIterator.outer == StandardLocation.SYSTEM_MODULES || |
291 moduleLocationIterator.outer == StandardLocation.UPGRADE_MODULE_PATH) { |
311 moduleLocationIterator.outer == StandardLocation.UPGRADE_MODULE_PATH) { |
292 msym.flags_field |= Flags.SYSTEM_MODULE; |
312 msym.flags_field |= Flags.SYSTEM_MODULE; |
293 } |
313 } |
294 if (toFind == msym || toFind == null) { |
314 if (toFind == null || |
|
315 (toFind == msym && (msym.sourceLocation != null || msym.classLocation != null))) { |
295 // Note: cannot return msym directly, because we must finish |
316 // Note: cannot return msym directly, because we must finish |
296 // processing this set first |
317 // processing this set first |
297 results.add(msym); |
318 results.add(msym); |
298 } |
319 } |
299 } else { |
320 } else { |
307 if (toFind != null && results.nonEmpty()) |
328 if (toFind != null && results.nonEmpty()) |
308 return results.toList(); |
329 return results.toList(); |
309 } |
330 } |
310 |
331 |
311 return results.toList(); |
332 return results.toList(); |
|
333 } |
|
334 |
|
335 private void checkModuleInfoOnLocation(Location location, Kind... kinds) throws IOException { |
|
336 if (location == null) |
|
337 return ; |
|
338 |
|
339 for (Kind kind : kinds) { |
|
340 JavaFileObject file = fileManager.getJavaFileForInput(location, |
|
341 names.module_info.toString(), |
|
342 kind); |
|
343 if (file != null) { |
|
344 log.error(Errors.LocnModuleInfoNotAllowedOnPatchPath(file)); |
|
345 return; |
|
346 } |
|
347 } |
312 } |
348 } |
313 |
349 |
314 private void findModuleInfo(ModuleSymbol msym) { |
350 private void findModuleInfo(ModuleSymbol msym) { |
315 try { |
351 try { |
316 JavaFileObject src_fo = (msym.sourceLocation == null) ? null |
352 JavaFileObject src_fo = (msym.sourceLocation == null) ? null |