Skip to content
Permalink
Browse files
8242282: Test sun/tools/jps/TestJps.java fails after JDK-8237572
Reviewed-by: dcubed, cjplummer
  • Loading branch information
Alex Menkov committed Apr 10, 2020
1 parent 8ace920 commit f11d4628c10c635b7d05b6eb2211f4f5b43a4ce0
Showing 2 changed files with 25 additions and 9 deletions.
@@ -69,26 +69,38 @@ public void buildJar() throws IOException {
File jar = new File(className + ".jar");
String testClassPath = System.getProperty("test.class.path", "?");

// Classpath contains test class dir, libraries class dir(s), and
// may contains some additional dirs.
// We need to add to jar only classes from the test class directory.
// Main class (this class) should only be found in one directory
// from the classpath (test class dir), therefore only added once.
// Libraries class dir(s) and any additional classpath directories
// are written the jar manifest.

File manifestFile = new File(className + ".mf");
String nl = System.getProperty("line.separator");
try (BufferedWriter output = new BufferedWriter(new FileWriter(manifestFile))) {
output.write("Main-Class: " + className + nl);
}
String manifestClasspath = "";

List<String> jarArgs = new ArrayList<>();
jarArgs.add("-cfm");
jarArgs.add(jar.getAbsolutePath());
jarArgs.add(manifestFile.getAbsolutePath());

for (String path : testClassPath.split(File.pathSeparator)) {
String classFullName = path + File.separator + className + ".class";
File f = new File(classFullName);
if (f.exists()) {
jarArgs.add("-C");
jarArgs.add(path);
jarArgs.add(".");
System.out.println("INFO: scheduled to jar " + path);
break;
jarArgs.add("-C");
jarArgs.add(path);
jarArgs.add(".");
System.out.println("INFO: scheduled to jar " + path);
} else {
manifestClasspath += " " + new File(path).toURI();
}
}
try (BufferedWriter output = new BufferedWriter(new FileWriter(manifestFile))) {
output.write("Main-Class: " + className + nl);
if (!manifestClasspath.isEmpty()) {
output.write("Class-Path: " + manifestClasspath + nl);
}
}

@@ -25,13 +25,17 @@
* @test
* @library /test/lib
* @modules jdk.jartool/sun.tools.jar
* @build jdk.test.lib.apps.LingeredApp
* @run main/othervm/timeout=360 TestJps
*/

/*
* Notes:
* @modules tag is ignored in driver mode, so need main/othervm
*
* LingeredApp is pre-built separately to have jdk.test.lib classes ready
* before the test is compiled (see JDK-8242282).
*
* Launching the process with relative path to an app jar file is not tested
*
* This test resides in default package, so correct appearance

0 comments on commit f11d462

Please sign in to comment.