< prev index next >
src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java
Print this page
*** 36,47 ****
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor;
- import java.lang.module.ModuleDescriptor.Exports;
- import java.lang.module.ModuleDescriptor.Opens;
import java.lang.module.ModuleFinder;
import java.lang.module.ModuleReader;
import java.lang.module.ModuleReference;
import java.lang.module.ResolvedModule;
import java.net.URI;
--- 36,45 ----
*** 69,78 ****
--- 67,77 ----
public class JdepsConfiguration implements AutoCloseable {
// the token for "all modules on the module path"
public static final String ALL_MODULE_PATH = "ALL-MODULE-PATH";
public static final String ALL_DEFAULT = "ALL-DEFAULT";
public static final String ALL_SYSTEM = "ALL-SYSTEM";
+
public static final String MODULE_INFO = "module-info.class";
private final SystemModuleFinder system;
private final ModuleFinder finder;
*** 89,100 ****
private JdepsConfiguration(SystemModuleFinder systemModulePath,
ModuleFinder finder,
Set<String> roots,
List<Path> classpaths,
List<Archive> initialArchives,
! boolean allDefaultModules,
! boolean allSystemModules,
Runtime.Version version)
throws IOException
{
trace("root: %s%n", roots);
--- 88,98 ----
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);
*** 102,121 ****
this.finder = finder;
this.version = version;
// build root set for resolution
Set<String> mods = new HashSet<>(roots);
!
! // add all system modules to the root set for unnamed module or set explicitly
! boolean unnamed = !initialArchives.isEmpty() || !classpaths.isEmpty();
! if (allSystemModules || (unnamed && !allDefaultModules)) {
systemModulePath.findAll().stream()
.map(mref -> mref.descriptor().name())
.forEach(mods::add);
}
! if (allDefaultModules) {
mods.addAll(systemModulePath.defaultSystemRoots());
}
this.configuration = Configuration.empty()
.resolve(finder, ModuleFinder.of(), mods);
--- 100,116 ----
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);
*** 198,208 ****
Objects.requireNonNull(name);
Module m = nameToModule.get(name);
return m!= null ? Optional.of(m.descriptor()) : Optional.empty();
}
! boolean isValidToken(String name) {
return ALL_MODULE_PATH.equals(name) ||
ALL_DEFAULT.equals(name) ||
ALL_SYSTEM.equals(name);
}
--- 193,203 ----
Objects.requireNonNull(name);
Module m = nameToModule.get(name);
return m!= null ? Optional.of(m.descriptor()) : Optional.empty();
}
! public static boolean isToken(String name) {
return ALL_MODULE_PATH.equals(name) ||
ALL_DEFAULT.equals(name) ||
ALL_SYSTEM.equals(name);
}
*** 480,496 ****
final SystemModuleFinder systemModulePath;
final Set<String> rootModules = new HashSet<>();
final List<Archive> initialArchives = new ArrayList<>();
final List<Path> paths = new ArrayList<>();
final List<Path> classPaths = new ArrayList<>();
ModuleFinder upgradeModulePath;
ModuleFinder appModulePath;
- boolean addAllApplicationModules;
- boolean addAllDefaultModules;
- boolean addAllSystemModules;
- boolean allModules;
Runtime.Version version;
public Builder() {
this.systemModulePath = new SystemModuleFinder();
}
--- 475,488 ----
final SystemModuleFinder systemModulePath;
final Set<String> rootModules = new HashSet<>();
final List<Archive> initialArchives = new ArrayList<>();
final List<Path> paths = new ArrayList<>();
final List<Path> classPaths = new ArrayList<>();
+ final Set<String> tokens = new HashSet<>();
ModuleFinder upgradeModulePath;
ModuleFinder appModulePath;
Runtime.Version version;
public Builder() {
this.systemModulePath = new SystemModuleFinder();
}
*** 511,548 ****
return this;
}
public Builder addmods(Set<String> addmods) {
for (String mn : addmods) {
! switch (mn) {
! case ALL_MODULE_PATH:
! this.addAllApplicationModules = true;
! break;
! case ALL_DEFAULT:
! this.addAllDefaultModules = true;
! break;
! case ALL_SYSTEM:
! this.addAllSystemModules = true;
! break;
! default:
! this.rootModules.add(mn);
}
}
return this;
}
- /*
- * This method is for --check option to find all target modules specified
- * in qualified exports.
- *
- * Include all system modules and modules found on modulepath
- */
- public Builder allModules() {
- this.allModules = true;
- return this;
- }
-
public Builder multiRelease(Runtime.Version version) {
this.version = version;
return this;
}
--- 503,521 ----
return this;
}
public Builder addmods(Set<String> addmods) {
for (String mn : addmods) {
! if (isToken(mn)) {
! tokens.add(mn);
! } else {
! rootModules.add(mn);
}
}
return this;
}
public Builder multiRelease(Runtime.Version version) {
this.version = version;
return this;
}
*** 577,609 ****
otherModulePath.findAll().stream()
.map(mref -> mref.descriptor().name())
.forEach(rootModules::add);
}
! if ((addAllApplicationModules || allModules) && 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 (addAllSystemModules && rootModules.isEmpty() &&
initialArchives.isEmpty() && classPaths.isEmpty()) {
systemModulePath.findAll()
.stream()
.map(mref -> mref.descriptor().name())
.forEach(rootModules::add);
}
return new JdepsConfiguration(systemModulePath,
finder,
rootModules,
classPaths,
initialArchives,
! addAllDefaultModules,
! allModules,
version);
}
private static ModuleFinder createModulePathFinder(String mpaths) {
if (mpaths == null) {
--- 550,587 ----
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) {
< prev index next >