430 Set<String> roots)
431 {
432 if (Objects.requireNonNull(paths).isEmpty()) {
433 throw new IllegalArgumentException("Empty module path");
434 }
435
436 Path[] entries = paths.toArray(new Path[0]);
437 Runtime.Version version = Runtime.version();
438 ModuleFinder finder = ModulePath.of(version, true, entries);
439
440 if (finder.find("java.base").isPresent()) {
441 // use the version of java.base module, if present, as
442 // the release version for multi-release JAR files
443 ModuleDescriptor.Version v = finder.find("java.base").get()
444 .descriptor().version().orElseThrow(() ->
445 new IllegalArgumentException("No version in java.base descriptor")
446 );
447
448 // java.base version is different than the current runtime version
449 version = Runtime.Version.parse(v.toString());
450 if (Runtime.version().major() != version.major()) {
451 finder = ModulePath.of(version, true, entries);
452 }
453 }
454
455 // if limitmods is specified then limit the universe
456 if (limitMods != null && !limitMods.isEmpty()) {
457 finder = limitFinder(finder, limitMods, Objects.requireNonNull(roots));
458 }
459 return finder;
460 }
461
462 private static Path toPathLocation(ResolvedModule m) {
463 Optional<URI> ouri = m.reference().location();
464 if (!ouri.isPresent())
465 throw new InternalError(m + " does not have a location");
466 URI uri = ouri.get();
467 return Paths.get(uri);
468 }
469
470
|
430 Set<String> roots)
431 {
432 if (Objects.requireNonNull(paths).isEmpty()) {
433 throw new IllegalArgumentException("Empty module path");
434 }
435
436 Path[] entries = paths.toArray(new Path[0]);
437 Runtime.Version version = Runtime.version();
438 ModuleFinder finder = ModulePath.of(version, true, entries);
439
440 if (finder.find("java.base").isPresent()) {
441 // use the version of java.base module, if present, as
442 // the release version for multi-release JAR files
443 ModuleDescriptor.Version v = finder.find("java.base").get()
444 .descriptor().version().orElseThrow(() ->
445 new IllegalArgumentException("No version in java.base descriptor")
446 );
447
448 // java.base version is different than the current runtime version
449 version = Runtime.Version.parse(v.toString());
450 if (Runtime.version().feature() != version.feature()) {
451 finder = ModulePath.of(version, true, entries);
452 }
453 }
454
455 // if limitmods is specified then limit the universe
456 if (limitMods != null && !limitMods.isEmpty()) {
457 finder = limitFinder(finder, limitMods, Objects.requireNonNull(roots));
458 }
459 return finder;
460 }
461
462 private static Path toPathLocation(ResolvedModule m) {
463 Optional<URI> ouri = m.reference().location();
464 if (!ouri.isPresent())
465 throw new InternalError(m + " does not have a location");
466 URI uri = ouri.get();
467 return Paths.get(uri);
468 }
469
470
|