equal
deleted
inserted
replaced
27 import java.io.File; |
27 import java.io.File; |
28 import java.io.IOException; |
28 import java.io.IOException; |
29 import java.io.PrintWriter; |
29 import java.io.PrintWriter; |
30 import java.io.UncheckedIOException; |
30 import java.io.UncheckedIOException; |
31 import java.lang.module.Configuration; |
31 import java.lang.module.Configuration; |
|
32 import java.lang.module.FindException; |
32 import java.lang.module.ModuleDescriptor; |
33 import java.lang.module.ModuleDescriptor; |
33 import java.lang.module.ModuleFinder; |
34 import java.lang.module.ModuleFinder; |
34 import java.lang.module.ModuleReference; |
35 import java.lang.module.ModuleReference; |
35 import java.lang.module.ResolutionException; |
36 import java.lang.module.ResolutionException; |
36 import java.lang.module.ResolvedModule; |
37 import java.lang.module.ResolvedModule; |
230 Files.write(Paths.get(options.saveoptsfile), getSaveOpts().getBytes()); |
231 Files.write(Paths.get(options.saveoptsfile), getSaveOpts().getBytes()); |
231 } |
232 } |
232 |
233 |
233 return EXIT_OK; |
234 return EXIT_OK; |
234 } catch (PluginException | IllegalArgumentException | |
235 } catch (PluginException | IllegalArgumentException | |
235 UncheckedIOException |IOException | ResolutionException e) { |
236 UncheckedIOException |IOException | FindException | ResolutionException e) { |
236 log.println(taskHelper.getMessage("error.prefix") + " " + e.getMessage()); |
237 log.println(taskHelper.getMessage("error.prefix") + " " + e.getMessage()); |
237 if (DEBUG) { |
238 if (DEBUG) { |
238 e.printStackTrace(log); |
239 e.printStackTrace(log); |
239 } |
240 } |
240 return EXIT_ERROR; |
241 return EXIT_ERROR; |
368 * Returns a module finder to find the observable modules specified in |
369 * Returns a module finder to find the observable modules specified in |
369 * the --module-path and --limit-modules options |
370 * the --module-path and --limit-modules options |
370 */ |
371 */ |
371 private ModuleFinder modulePathFinder() { |
372 private ModuleFinder modulePathFinder() { |
372 Path[] entries = options.modulePath.toArray(new Path[0]); |
373 Path[] entries = options.modulePath.toArray(new Path[0]); |
373 ModuleFinder finder = new ModulePath(Runtime.version(), true, entries); |
374 ModuleFinder finder = ModulePath.of(Runtime.version(), true, entries); |
374 if (!options.limitMods.isEmpty()) { |
375 if (!options.limitMods.isEmpty()) { |
375 finder = limitFinder(finder, options.limitMods, Collections.emptySet()); |
376 finder = limitFinder(finder, options.limitMods, Collections.emptySet()); |
376 } |
377 } |
377 return finder; |
378 return finder; |
378 } |
379 } |
386 public static ModuleFinder newModuleFinder(List<Path> paths, |
387 public static ModuleFinder newModuleFinder(List<Path> paths, |
387 Set<String> limitMods, |
388 Set<String> limitMods, |
388 Set<String> roots) |
389 Set<String> roots) |
389 { |
390 { |
390 Path[] entries = paths.toArray(new Path[0]); |
391 Path[] entries = paths.toArray(new Path[0]); |
391 ModuleFinder finder = new ModulePath(Runtime.version(), true, entries); |
392 ModuleFinder finder = ModulePath.of(Runtime.version(), true, entries); |
392 |
393 |
393 // if limitmods is specified then limit the universe |
394 // if limitmods is specified then limit the universe |
394 if (!limitMods.isEmpty()) { |
395 if (!limitMods.isEmpty()) { |
395 finder = limitFinder(finder, limitMods, roots); |
396 finder = limitFinder(finder, limitMods, roots); |
396 } |
397 } |
416 if (roots.isEmpty()) { |
417 if (roots.isEmpty()) { |
417 throw new IllegalArgumentException("empty modules and limitmods"); |
418 throw new IllegalArgumentException("empty modules and limitmods"); |
418 } |
419 } |
419 |
420 |
420 Configuration cf = Configuration.empty() |
421 Configuration cf = Configuration.empty() |
421 .resolveRequires(finder, |
422 .resolve(finder, |
422 ModuleFinder.of(), |
423 ModuleFinder.of(), |
423 roots); |
424 roots); |
424 |
425 |
425 // emit warning for modules that end with a digit |
426 // emit warning for modules that end with a digit |
426 cf.modules().stream() |
427 cf.modules().stream() |
427 .map(ResolvedModule::name) |
428 .map(ResolvedModule::name) |
428 .filter(mn -> !Checks.hasLegalModuleNameLastCharacter(mn)) |
429 .filter(mn -> !Checks.hasLegalModuleNameLastCharacter(mn)) |
456 Set<String> roots, |
457 Set<String> roots, |
457 Set<String> otherMods) { |
458 Set<String> otherMods) { |
458 |
459 |
459 // resolve all root modules |
460 // resolve all root modules |
460 Configuration cf = Configuration.empty() |
461 Configuration cf = Configuration.empty() |
461 .resolveRequires(finder, |
462 .resolve(finder, |
462 ModuleFinder.of(), |
463 ModuleFinder.of(), |
463 roots); |
464 roots); |
464 |
465 |
465 // module name -> reference |
466 // module name -> reference |
466 Map<String, ModuleReference> map = new HashMap<>(); |
467 Map<String, ModuleReference> map = new HashMap<>(); |
467 cf.modules().forEach(m -> { |
468 cf.modules().forEach(m -> { |
468 ModuleReference mref = m.reference(); |
469 ModuleReference mref = m.reference(); |