< prev index next >
src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java
Print this page
*** 81,124 ****
private final Map<String, List<Archive>> packageToUnnamedModule = new HashMap<>();
private final List<Archive> classpathArchives = new ArrayList<>();
private final List<Archive> initialArchives = new ArrayList<>();
private final Set<Module> rootModules = new HashSet<>();
- private final Configuration configuration;
private final Runtime.Version version;
! private JdepsConfiguration(SystemModuleFinder systemModulePath,
ModuleFinder finder,
Set<String> roots,
List<Path> classpaths,
List<Archive> initialArchives,
- Set<String> tokens,
Runtime.Version version)
throws IOException
{
trace("root: %s%n", roots);
-
this.system = systemModulePath;
this.finder = finder;
this.version = version;
! // build root set for resolution
! Set<String> mods = new HashSet<>(roots);
! if (tokens.contains(ALL_SYSTEM)) {
! systemModulePath.findAll().stream()
! .map(mref -> mref.descriptor().name())
! .forEach(mods::add);
! }
!
! if (tokens.contains(ALL_DEFAULT)) {
! mods.addAll(systemModulePath.defaultSystemRoots());
! }
!
! this.configuration = Configuration.empty()
! .resolve(finder, ModuleFinder.of(), mods);
!
! this.configuration.modules().stream()
.map(ResolvedModule::reference)
.forEach(this::addModuleReference);
// packages in unnamed module
initialArchives.forEach(archive -> {
--- 81,107 ----
private final Map<String, List<Archive>> packageToUnnamedModule = new HashMap<>();
private final List<Archive> classpathArchives = new ArrayList<>();
private final List<Archive> initialArchives = new ArrayList<>();
private final Set<Module> rootModules = new HashSet<>();
private final Runtime.Version version;
! private JdepsConfiguration(Configuration config,
! SystemModuleFinder systemModulePath,
ModuleFinder finder,
Set<String> roots,
List<Path> classpaths,
List<Archive> initialArchives,
Runtime.Version version)
throws IOException
{
trace("root: %s%n", roots);
this.system = systemModulePath;
this.finder = finder;
this.version = version;
! config.modules().stream()
.map(ResolvedModule::reference)
.forEach(this::addModuleReference);
// packages in unnamed module
initialArchives.forEach(archive -> {
*** 536,573 ****
otherModulePath.findAll().stream()
.map(mref -> mref.descriptor().name())
.forEach(rootModules::add);
}
- // add all modules to the root set for unnamed module or set explicitly
- boolean unnamed = !initialArchives.isEmpty() || !classPaths.isEmpty();
- if ((unnamed || tokens.contains(ALL_MODULE_PATH)) && appModulePath != null) {
- appModulePath.findAll().stream()
- .map(mref -> mref.descriptor().name())
- .forEach(rootModules::add);
- }
-
// no archive is specified for analysis
// add all system modules as root if --add-modules ALL-SYSTEM is specified
if (tokens.contains(ALL_SYSTEM) && rootModules.isEmpty() &&
initialArchives.isEmpty() && classPaths.isEmpty()) {
systemModulePath.findAll()
.stream()
.map(mref -> mref.descriptor().name())
.forEach(rootModules::add);
}
! if (unnamed && !tokens.contains(ALL_DEFAULT)) {
! tokens.add(ALL_SYSTEM);
}
! return new JdepsConfiguration(systemModulePath,
finder,
rootModules,
classPaths,
initialArchives,
- tokens,
version);
}
private static ModuleFinder createModulePathFinder(String mpaths) {
if (mpaths == null) {
--- 519,573 ----
otherModulePath.findAll().stream()
.map(mref -> mref.descriptor().name())
.forEach(rootModules::add);
}
// no archive is specified for analysis
// add all system modules as root if --add-modules ALL-SYSTEM is specified
if (tokens.contains(ALL_SYSTEM) && rootModules.isEmpty() &&
initialArchives.isEmpty() && classPaths.isEmpty()) {
systemModulePath.findAll()
.stream()
.map(mref -> mref.descriptor().name())
.forEach(rootModules::add);
}
! // add all modules on app module path as roots if ALL-MODULE-PATH is specified
! if ((tokens.contains(ALL_MODULE_PATH)) && appModulePath != null) {
! appModulePath.findAll().stream()
! .map(mref -> mref.descriptor().name())
! .forEach(rootModules::add);
! }
!
!
! // build root set for module resolution
! Set<String> mods = new HashSet<>(rootModules);
! // if archives are specified for analysis, then consider as unnamed module
! boolean unnamed = !initialArchives.isEmpty() || !classPaths.isEmpty();
! if (tokens.contains(ALL_DEFAULT)) {
! mods.addAll(systemModulePath.defaultSystemRoots());
! } else if (tokens.contains(ALL_SYSTEM) || unnamed) {
! // resolve all system modules as unnamed module may reference any class
! systemModulePath.findAll().stream()
! .map(mref -> mref.descriptor().name())
! .forEach(mods::add);
! }
! if (unnamed && appModulePath != null) {
! // resolve all modules on module path as unnamed module may reference any class
! appModulePath.findAll().stream()
! .map(mref -> mref.descriptor().name())
! .forEach(mods::add);
}
! // resolve the module graph
! Configuration config = Configuration.empty().resolve(finder, ModuleFinder.of(), mods);
! return new JdepsConfiguration(config,
! systemModulePath,
finder,
rootModules,
classPaths,
initialArchives,
version);
}
private static ModuleFinder createModulePathFinder(String mpaths) {
if (mpaths == null) {
< prev index next >