8157391: jdeps left JarFile open

Reviewed-by: alanb
This commit is contained in:
Mandy Chung 2016-05-20 09:47:00 -07:00
parent 6db305ee0d
commit 479ecdbdaf
12 changed files with 257 additions and 212 deletions

View File

@ -27,6 +27,7 @@ package com.sun.tools.jdeps;
import com.sun.tools.classfile.Dependency.Location;
import java.io.Closeable;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.URI;
@ -43,7 +44,7 @@ import java.util.stream.Stream;
/**
* Represents the source of the class files.
*/
public class Archive {
public class Archive implements Closeable {
public static Archive getInstance(Path p) {
try {
return new Archive(p, ClassFileReader.newInstance(p));
@ -178,6 +179,13 @@ public class Archive {
private boolean isJrt() {
return location != null && location.getScheme().equals("jrt");
}
@Override
public void close() throws IOException {
if (reader != null)
reader.close();
}
interface Visitor {
void visit(Location origin, Location target);
}

View File

@ -29,6 +29,7 @@ import com.sun.tools.classfile.ClassFile;
import com.sun.tools.classfile.ConstantPoolException;
import com.sun.tools.classfile.Dependencies.ClassFileError;
import java.io.Closeable;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@ -54,7 +55,7 @@ import java.util.stream.Stream;
* ClassFileReader reads ClassFile(s) of a given path that can be
* a .class file, a directory, or a JAR file.
*/
public class ClassFileReader {
public class ClassFileReader implements Closeable {
/**
* Returns a ClassFileReader instance of a given path.
*/
@ -177,6 +178,10 @@ public class ClassFileReader {
return fn.endsWith(".class");
}
@Override
public void close() throws IOException {
}
class FileIterator implements Iterator<ClassFile> {
int count;
FileIterator() {
@ -306,6 +311,11 @@ public class ClassFileReader {
this.jarfile = jf;
}
@Override
public void close() throws IOException {
jarfile.close();
}
protected Set<String> scan() {
try (JarFile jf = new JarFile(path.toFile())) {
return jf.stream().map(JarEntry::getName)

View File

@ -64,7 +64,7 @@ import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Stream;
public class JdepsConfiguration {
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";
@ -304,6 +304,19 @@ public class JdepsConfiguration {
}
}
/*
* Close all archives e.g. JarFile
*/
@Override
public void close() throws IOException {
for (Archive archive : initialArchives)
archive.close();
for (Archive archive : classpathArchives)
archive.close();
for (Module module : nameToModule.values())
module.close();
}
static class SystemModuleFinder implements ModuleFinder {
private static final String JAVA_HOME = System.getProperty("java.home");
private static final String JAVA_SE = "java.se";

View File

@ -499,40 +499,41 @@ class JdepsTask {
}
boolean run() throws IOException {
JdepsConfiguration config = buildConfig();
try (JdepsConfiguration config = buildConfig()) {
// detect split packages
config.splitPackages().entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.forEach(e -> System.out.format("split package: %s %s%n", e.getKey(),
e.getValue().toString()));
// detect split packages
config.splitPackages().entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.forEach(e -> System.out.format("split package: %s %s%n", e.getKey(),
e.getValue().toString()));
// check if any module specified in -requires is missing
Stream.concat(options.addmods.stream(), options.requires.stream())
.filter(mn -> !config.isValidToken(mn))
.forEach(mn -> config.findModule(mn).orElseThrow(() ->
new UncheckedBadArgs(new BadArgs("err.module.not.found", mn))));
// check if any module specified in -requires is missing
Stream.concat(options.addmods.stream(), options.requires.stream())
.filter(mn -> !config.isValidToken(mn))
.forEach(mn -> config.findModule(mn).orElseThrow(() ->
new UncheckedBadArgs(new BadArgs("err.module.not.found", mn))));
// -genmoduleinfo
if (options.genModuleInfo != null) {
return genModuleInfo(config);
}
// -genmoduleinfo
if (options.genModuleInfo != null) {
return genModuleInfo(config);
}
// -check
if (options.checkModuleDeps != null) {
return new ModuleAnalyzer(config, log, options.checkModuleDeps).run();
}
// -check
if (options.checkModuleDeps != null) {
return new ModuleAnalyzer(config, log, options.checkModuleDeps).run();
}
if (options.dotOutputDir != null &&
if (options.dotOutputDir != null &&
(options.verbose == SUMMARY || options.verbose == MODULE) &&
!options.addmods.isEmpty() && inputArgs.isEmpty()) {
return new ModuleAnalyzer(config, log).genDotFiles(options.dotOutputDir);
}
return new ModuleAnalyzer(config, log).genDotFiles(options.dotOutputDir);
}
if (options.inverse) {
return analyzeInverseDeps(config);
} else {
return analyzeDeps(config);
if (options.inverse) {
return analyzeInverseDeps(config);
} else {
return analyzeDeps(config);
}
}
}

View File

@ -119,6 +119,11 @@ public class ModuleInfoBuilder {
// generate module-info.java
descriptors().forEach(md -> writeModuleInfo(outputdir, md));
// done parsing
for (Module m : automaticModules()) {
m.close();
}
// find any missing dependences
return automaticModules().stream()
.flatMap(analyzer::requires)

View File

@ -29,6 +29,7 @@ import com.sun.tools.jdeps.JdepsFilter;
import com.sun.tools.jdeps.JdepsWriter;
import com.sun.tools.jdeps.ModuleAnalyzer;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
@ -73,7 +74,7 @@ public final class JdepsUtil {
return new Command(cmd);
}
public static class Command {
public static class Command implements Closeable {
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw);
@ -81,6 +82,7 @@ public final class JdepsUtil {
final JdepsConfiguration.Builder builder = new JdepsConfiguration.Builder();
final Set<String> requires = new HashSet<>();
JdepsConfiguration configuration;
Analyzer.Type verbose = Analyzer.Type.PACKAGE;
boolean apiOnly = false;
@ -176,12 +178,14 @@ public final class JdepsUtil {
}
public JdepsConfiguration configuration() throws IOException {
JdepsConfiguration config = builder.build();
requires.forEach(name -> {
ModuleDescriptor md = config.findModuleDescriptor(name).get();
filter.requires(name, md.packages());
});
return config;
if (configuration == null) {
this.configuration = builder.build();
requires.forEach(name -> {
ModuleDescriptor md = configuration.findModuleDescriptor(name).get();
filter.requires(name, md.packages());
});
}
return configuration;
}
private JdepsWriter writer() {
@ -208,6 +212,11 @@ public final class JdepsUtil {
public void dumpOutput(PrintStream out) {
out.println(sw.toString());
}
@Override
public void close() throws IOException {
configuration.close();
}
}
/**

View File

@ -78,19 +78,19 @@ public class CheckModuleTest {
@Test(dataProvider = "javaBase")
public void testJavaBase(String name, ModuleMetaData data) throws Exception {
JdepsUtil.Command jdeps = JdepsUtil.newCommand(
String.format("jdeps -check %s -mp %s%n", name, MODS_DIR)
);
jdeps.appModulePath(MODS_DIR.toString());
String cmd = String.format("jdeps -check %s -mp %s%n", name, MODS_DIR);
try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
jdeps.appModulePath(MODS_DIR.toString());
ModuleAnalyzer analyzer = jdeps.getModuleAnalyzer(Set.of(name));
assertTrue(analyzer.run());
jdeps.dumpOutput(System.err);
ModuleAnalyzer analyzer = jdeps.getModuleAnalyzer(Set.of(name));
assertTrue(analyzer.run());
jdeps.dumpOutput(System.err);
ModuleDescriptor[] descriptors = analyzer.descriptors(name);
for (int i=0; i < 3; i++) {
descriptors[i].requires().stream()
.forEach(req -> data.checkRequires(req));
ModuleDescriptor[] descriptors = analyzer.descriptors(name);
for (int i = 0; i < 3; i++) {
descriptors[i].requires().stream()
.forEach(req -> data.checkRequires(req));
}
}
}
@ -137,26 +137,27 @@ public class CheckModuleTest {
@Test(dataProvider = "modules")
public void modularTest(String name, ModuleMetaData[] data) throws Exception {
JdepsUtil.Command jdeps = JdepsUtil.newCommand(
String.format("jdeps -check %s -mp %s%n", name, MODS_DIR)
);
jdeps.appModulePath(MODS_DIR.toString());
String cmd = String.format("jdeps -check %s -mp %s%n", name, MODS_DIR);
ModuleAnalyzer analyzer = jdeps.getModuleAnalyzer(Set.of(name));
assertTrue(analyzer.run());
jdeps.dumpOutput(System.err);
try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
jdeps.appModulePath(MODS_DIR.toString());
// compare the module descriptors and the suggested versions
ModuleDescriptor[] descriptors = analyzer.descriptors(name);
for (int i=0; i < 3; i++) {
ModuleMetaData metaData = data[i];
descriptors[i].requires().stream()
.forEach(req -> metaData.checkRequires(req));
ModuleAnalyzer analyzer = jdeps.getModuleAnalyzer(Set.of(name));
assertTrue(analyzer.run());
jdeps.dumpOutput(System.err);
// compare the module descriptors and the suggested versions
ModuleDescriptor[] descriptors = analyzer.descriptors(name);
for (int i = 0; i < 3; i++) {
ModuleMetaData metaData = data[i];
descriptors[i].requires().stream()
.forEach(req -> metaData.checkRequires(req));
}
Map<String, Set<String>> unused = analyzer.unusedQualifiedExports(name);
// verify unuused qualified exports
assertEquals(unused, data[0].exports);
}
Map<String, Set<String>> unused = analyzer.unusedQualifiedExports(name);
// verify unuused qualified exports
assertEquals(unused, data[0].exports);
}
}

View File

@ -107,8 +107,7 @@ public class GenModuleInfo {
.map(Path::toString);
JdepsUtil.jdeps(Stream.concat(Stream.of("-genmoduleinfo", DEST_DIR.toString()),
files)
.toArray(String[]::new));
files).toArray(String[]::new));
// check file exists
Arrays.stream(modules)
@ -162,14 +161,13 @@ public class GenModuleInfo {
}
private Set<String> packages(Path dir) {
try {
return Files.find(dir, Integer.MAX_VALUE,
try (Stream<Path> stream = Files.find(dir, Integer.MAX_VALUE,
((path, attrs) -> attrs.isRegularFile() &&
path.toString().endsWith(".class")))
.map(path -> toPackageName(dir.relativize(path)))
.filter(pkg -> pkg.length() > 0) // module-info
.distinct()
.collect(Collectors.toSet());
path.toString().endsWith(".class")))) {
return stream.map(path -> toPackageName(dir.relativize(path)))
.filter(pkg -> pkg.length() > 0) // module-info
.distinct()
.collect(Collectors.toSet());
} catch (IOException x) {
throw new UncheckedIOException(x);
}

View File

@ -117,26 +117,28 @@ public class InverseDeps {
@Test(dataProvider = "testrequires")
public void testrequires(String name, String[][] expected) throws Exception {
JdepsUtil.Command jdeps = JdepsUtil.newCommand(
String.format("jdeps -inverse -modulepath %s -requires %s -addmods %s%n",
MODS_DIR, name, modules.stream().collect(Collectors.joining(","))
));
jdeps.appModulePath(MODS_DIR.toString())
.addmods(modules)
.requires(Set.of(name));
String cmd1 = String.format("jdeps -inverse -modulepath %s -requires %s -addmods %s%n",
MODS_DIR, name, modules.stream().collect(Collectors.joining(",")));
runJdeps(jdeps, expected);
try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd1)) {
jdeps.appModulePath(MODS_DIR.toString())
.addmods(modules)
.requires(Set.of(name));
// automatic module
jdeps = JdepsUtil.newCommand(
String.format("jdeps -inverse -modulepath %s -requires %s -addmods ALL-MODULE-PATH%n",
LIBS_DIR, name)
);
jdeps.appModulePath(MODS_DIR.toString())
.addmods(Set.of("ALL-MODULE-PATH"))
.requires(Set.of(name));
runJdeps(jdeps, expected);
}
runJdeps(jdeps, expected);
String cmd2 = String.format("jdeps -inverse -modulepath %s -requires %s" +
" -addmods ALL-MODULE-PATH%n", LIBS_DIR, name);
// automatic module
try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd2)) {
jdeps.appModulePath(MODS_DIR.toString())
.addmods(Set.of("ALL-MODULE-PATH"))
.requires(Set.of(name));
runJdeps(jdeps, expected);
}
}
@DataProvider(name = "testpackage")
@ -162,15 +164,15 @@ public class InverseDeps {
@Test(dataProvider = "testpackage")
public void testpackage(String name, String[][] expected) throws Exception {
JdepsUtil.Command jdeps = JdepsUtil.newCommand(
String.format("jdeps -inverse -modulepath %s -package %s -addmods %s%n",
MODS_DIR, name, modules.stream().collect(Collectors.joining(","))
));
jdeps.appModulePath(MODS_DIR.toString())
.addmods(modules)
.matchPackages(Set.of(name));
String cmd = String.format("jdeps -inverse -modulepath %s -package %s -addmods %s%n",
MODS_DIR, name, modules.stream().collect(Collectors.joining(",")));
try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
jdeps.appModulePath(MODS_DIR.toString())
.addmods(modules)
.matchPackages(Set.of(name));
runJdeps(jdeps, expected);
runJdeps(jdeps, expected);
}
}
@DataProvider(name = "testregex")
@ -193,16 +195,16 @@ public class InverseDeps {
@Test(dataProvider = "testregex")
public void testregex(String name, String[][] expected) throws Exception {
JdepsUtil.Command jdeps = JdepsUtil.newCommand(
String.format("jdeps -inverse -modulepath %s -regex %s -addmods %s%n",
MODS_DIR, name, modules.stream().collect(Collectors.joining(",")))
);
String cmd = String.format("jdeps -inverse -modulepath %s -regex %s -addmods %s%n",
MODS_DIR, name, modules.stream().collect(Collectors.joining(",")));
jdeps.appModulePath(MODS_DIR.toString())
.addmods(modules)
.regex(name);
try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
jdeps.appModulePath(MODS_DIR.toString())
.addmods(modules)
.regex(name);
runJdeps(jdeps, expected);
runJdeps(jdeps, expected);
}
}
@DataProvider(name = "classpath")
@ -237,26 +239,26 @@ public class InverseDeps {
.collect(Collectors.joining(File.pathSeparator));
Path jarfile = LIBS_DIR.resolve("m7.jar");
JdepsUtil.Command jdeps = JdepsUtil.newCommand(
String.format("jdeps -inverse -classpath %s -regex %s %s%n",
cpath, name, jarfile)
);
jdeps.verbose("-verbose:class")
.addClassPath(cpath)
.regex(name).addRoot(jarfile);
runJdeps(jdeps, expected);
String cmd1 = String.format("jdeps -inverse -classpath %s -regex %s %s%n",
cpath, name, jarfile);
try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd1)) {
jdeps.verbose("-verbose:class")
.addClassPath(cpath)
.regex(name).addRoot(jarfile);
runJdeps(jdeps, expected);
}
// all JAR files on the command-line arguments
Set<Path> paths = modules.stream()
.map(mn -> LIBS_DIR.resolve(mn + ".jar"))
.collect(Collectors.toSet());
jdeps = JdepsUtil.newCommand(
String.format("jdeps -inverse -regex %s %s%n", name, paths)
);
jdeps.verbose("-verbose:class").regex(name);
paths.forEach(jdeps::addRoot);
runJdeps(jdeps, expected);
.map(mn -> LIBS_DIR.resolve(mn + ".jar"))
.collect(Collectors.toSet());
String cmd2 = String.format("jdeps -inverse -regex %s %s%n", name, paths);
try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd2)) {
jdeps.verbose("-verbose:class").regex(name);
paths.forEach(jdeps::addRoot);
runJdeps(jdeps, expected);
}
}
private void runJdeps(JdepsUtil.Command jdeps, String[][] expected) throws Exception {
@ -292,7 +294,6 @@ public class InverseDeps {
assertFalse(noneMatched);
}
}
}

View File

@ -151,30 +151,30 @@ public class ModuleTest {
throws IOException
{
// jdeps -modulepath <modulepath> -m root paths
String cmd = String.format("jdeps -modulepath %s -addmods %s %s%n",
MODS_DIR, roots.stream().collect(Collectors.joining(",")), paths);
JdepsUtil.Command jdeps = JdepsUtil.newCommand(
String.format("jdeps -modulepath %s -addmods %s %s%n", MODS_DIR,
roots.stream().collect(Collectors.joining(",")), paths)
);
jdeps.appModulePath(modulepath)
.addmods(roots);
Arrays.stream(paths).forEach(jdeps::addRoot);
try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
jdeps.appModulePath(modulepath)
.addmods(roots);
Arrays.stream(paths).forEach(jdeps::addRoot);
// run the analyzer
DepsAnalyzer analyzer = jdeps.getDepsAnalyzer();
assertTrue(analyzer.run());
// run the analyzer
DepsAnalyzer analyzer = jdeps.getDepsAnalyzer();
assertTrue(analyzer.run());
// analyze result
Graph<DepsAnalyzer.Node> g1 = analyzer.moduleGraph();
g1.nodes().stream()
.filter(u -> u.name.equals(data.moduleName))
.forEach(u -> data.checkRequires(u.name, g1.adjacentNodes(u)));
// analyze result
Graph<DepsAnalyzer.Node> g1 = analyzer.moduleGraph();
g1.nodes().stream()
.filter(u -> u.name.equals(data.moduleName))
.forEach(u -> data.checkRequires(u.name, g1.adjacentNodes(u)));
Graph<DepsAnalyzer.Node> g2 = analyzer.dependenceGraph();
g2.nodes().stream()
.filter(u -> u.name.equals(data.moduleName))
.forEach(u -> data.checkDependences(u.name, g2.adjacentNodes(u)));
Graph<DepsAnalyzer.Node> g2 = analyzer.dependenceGraph();
g2.nodes().stream()
.filter(u -> u.name.equals(data.moduleName))
.forEach(u -> data.checkDependences(u.name, g2.adjacentNodes(u)));
jdeps.dumpOutput(System.err);
jdeps.dumpOutput(System.err);
}
}
}

View File

@ -70,36 +70,35 @@ public class SplitPackage {
}
private void runTest(String root, String... splitPackages) throws Exception {
JdepsUtil.Command jdeps = JdepsUtil.newCommand(
String.format("jdeps -verbose:class -addmods %s %s%n",
root, CLASSES_DIR)
);
jdeps.verbose("-verbose:class")
.addRoot(CLASSES_DIR);
if (root != null)
jdeps.addmods(Set.of(root));
String cmd = String.format("jdeps -verbose:class -addmods %s %s%n",
root, CLASSES_DIR);
try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
jdeps.verbose("-verbose:class")
.addRoot(CLASSES_DIR);
if (root != null)
jdeps.addmods(Set.of(root));
JdepsConfiguration config = jdeps.configuration();
Map<String, Set<String>> pkgs = config.splitPackages();
JdepsConfiguration config = jdeps.configuration();
Map<String, Set<String>> pkgs = config.splitPackages();
final Set<String> expected;
if (splitPackages != null) {
expected = Arrays.stream(splitPackages).collect(Collectors.toSet());
} else {
expected = Collections.emptySet();
final Set<String> expected;
if (splitPackages != null) {
expected = Arrays.stream(splitPackages).collect(Collectors.toSet());
} else {
expected = Collections.emptySet();
}
if (!pkgs.keySet().equals(expected)) {
throw new RuntimeException(splitPackages.toString());
}
// java.annotations.common is not observable
DepsAnalyzer analyzer = jdeps.getDepsAnalyzer();
assertTrue(analyzer.run());
jdeps.dumpOutput(System.err);
}
if (!pkgs.keySet().equals(expected)) {
throw new RuntimeException(splitPackages.toString());
}
// java.annotations.common is not observable
DepsAnalyzer analyzer = jdeps.getDepsAnalyzer();
assertTrue(analyzer.run());
jdeps.dumpOutput(System.err);
}
}

View File

@ -122,30 +122,31 @@ public class TransitiveDeps {
@Test(dataProvider = "modules")
public void testModulePath(String name, List<ModuleMetaData> data) throws IOException {
Set<String> roots = Set.of("m6", "unsafe");
JdepsUtil.Command jdeps = JdepsUtil.newCommand(
String.format("jdeps -modulepath %s -addmods %s -m %s%n", MODS_DIR,
roots.stream().collect(Collectors.joining(",")), name)
);
jdeps.verbose("-verbose:class")
.appModulePath(MODS_DIR.toString())
.addmods(roots)
.addmods(Set.of(name));
runJdeps(jdeps, data);
String cmd1 = String.format("jdeps -modulepath %s -addmods %s -m %s%n", MODS_DIR,
roots.stream().collect(Collectors.joining(",")), name);
try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd1)) {
jdeps.verbose("-verbose:class")
.appModulePath(MODS_DIR.toString())
.addmods(roots)
.addmods(Set.of(name));
runJdeps(jdeps, data);
}
// run automatic modules
roots = Set.of("ALL-MODULE-PATH", "jdk.unsupported");
jdeps = JdepsUtil.newCommand(
String.format("jdeps -modulepath %s -addmods %s -m %s%n", LIBS_DIR,
roots.stream().collect(Collectors.joining(",")), name)
);
jdeps.verbose("-verbose:class")
.appModulePath(LIBS_DIR.toString())
.addmods(roots)
.addmods(Set.of(name));
String cmd2 = String.format("jdeps -modulepath %s -addmods %s -m %s%n", LIBS_DIR,
roots.stream().collect(Collectors.joining(",")), name);
runJdeps(jdeps, data);
try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd2)) {
jdeps.verbose("-verbose:class")
.appModulePath(LIBS_DIR.toString())
.addmods(roots)
.addmods(Set.of(name));
runJdeps(jdeps, data);
}
}
@DataProvider(name = "jars")
@ -170,14 +171,15 @@ public class TransitiveDeps {
.collect(Collectors.joining(File.pathSeparator));
Path jarfile = LIBS_DIR.resolve(name + ".jar");
JdepsUtil.Command jdeps = JdepsUtil.newCommand(
String.format("jdeps -classpath %s %s%n", cpath, jarfile)
);
jdeps.verbose("-verbose:class")
.addClassPath(cpath)
.addRoot(jarfile);
runJdeps(jdeps, data);
String cmd = String.format("jdeps -classpath %s %s%n", cpath, jarfile);
try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
jdeps.verbose("-verbose:class")
.addClassPath(cpath)
.addRoot(jarfile);
runJdeps(jdeps, data);
}
}
@DataProvider(name = "compileTimeView")
@ -225,15 +227,14 @@ public class TransitiveDeps {
Path jarfile = LIBS_DIR.resolve(name + ".jar");
JdepsUtil.Command jdeps = JdepsUtil.newCommand(
String.format("jdeps -ct -classpath %s %s%n", cpath, jarfile)
);
String cmd = String.format("jdeps -ct -classpath %s %s%n", cpath, jarfile);
try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
jdeps.verbose("-verbose:class")
.addClassPath(cpath)
.addRoot(jarfile);
jdeps.verbose("-verbose:class")
.addClassPath(cpath)
.addRoot(jarfile);
runJdeps(jdeps, data, true, 0 /* -recursive */);
runJdeps(jdeps, data, true, 0 /* -recursive */);
}
}
@DataProvider(name = "recursiveDeps")
@ -276,14 +277,14 @@ public class TransitiveDeps {
Path jarfile = LIBS_DIR.resolve(name + ".jar");
JdepsUtil.Command jdeps = JdepsUtil.newCommand(
String.format("jdeps -R -classpath %s %s%n", cpath, jarfile)
);
jdeps.verbose("-verbose:class").filter("-filter:archive")
.addClassPath(cpath)
.addRoot(jarfile);
String cmd = String.format("jdeps -R -classpath %s %s%n", cpath, jarfile);
try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
jdeps.verbose("-verbose:class").filter("-filter:archive")
.addClassPath(cpath)
.addRoot(jarfile);
runJdeps(jdeps, data, true, 0 /* -recursive */);
runJdeps(jdeps, data, true, 0 /* -recursive */);
}
}
private void runJdeps(JdepsUtil.Command jdeps, List<ModuleMetaData> data)
@ -322,6 +323,5 @@ public class TransitiveDeps {
ModuleMetaData md = dataMap.get(u.name);
md.checkDependences(u.name, g2.adjacentNodes(u));
});
}
}