< prev index next >
test/tools/jlink/basic/BasicTest.java
Print this page
*** 25,36 ****
* @test
* @summary Basic test of jlink to create jmods and images
* @author Andrei Eremeev
* @library /lib/testlibrary
* @modules java.base/jdk.internal.module
! * jdk.jlink/jdk.tools.jlink.internal
! * jdk.jlink/jdk.tools.jmod
* jdk.compiler
* @build jdk.testlibrary.ProcessTools
* jdk.testlibrary.OutputAnalyzer
* JarUtils CompilerUtils
* @run main BasicTest
--- 25,35 ----
* @test
* @summary Basic test of jlink to create jmods and images
* @author Andrei Eremeev
* @library /lib/testlibrary
* @modules java.base/jdk.internal.module
! * jdk.jlink
* jdk.compiler
* @build jdk.testlibrary.ProcessTools
* jdk.testlibrary.OutputAnalyzer
* JarUtils CompilerUtils
* @run main BasicTest
*** 42,56 ****
--- 41,58 ----
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+ import java.util.spi.ToolProvider;
import jdk.testlibrary.OutputAnalyzer;
import jdk.testlibrary.ProcessTools;
public class BasicTest {
+ static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod").get();
+ static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink").get();
private final Path jdkHome = Paths.get(System.getProperty("test.jdk"));
private final Path jdkMods = jdkHome.resolve("jmods");
private final Path testSrc = Paths.get(System.getProperty("test.src"));
private final Path src = testSrc.resolve("src");
*** 108,131 ****
Collections.addAll(args,
"--module-path", jdkMods + File.pathSeparator + jmods,
"--add-modules", modName,
"--output", image.toString());
Collections.addAll(args, options);
! int rc = jdk.tools.jlink.internal.Main.run(args.toArray(new String[args.size()]), new PrintWriter(System.out));
if (rc != 0) {
throw new AssertionError("Jlink failed: rc = " + rc);
}
}
private void runJmod(String cp, String modName) {
! int rc = jdk.tools.jmod.Main.run(new String[] {
"create",
"--class-path", cp,
"--module-version", "1.0",
"--main-class", "jdk.test.Test",
jmods.resolve(modName + ".jmod").toString(),
! }, System.out);
if (rc != 0) {
throw new AssertionError("Jmod failed: rc = " + rc);
}
}
}
--- 110,135 ----
Collections.addAll(args,
"--module-path", jdkMods + File.pathSeparator + jmods,
"--add-modules", modName,
"--output", image.toString());
Collections.addAll(args, options);
!
! PrintWriter pw = new PrintWriter(System.out);
! int rc = JLINK_TOOL.run(pw, pw, args.toArray(new String[args.size()]));
if (rc != 0) {
throw new AssertionError("Jlink failed: rc = " + rc);
}
}
private void runJmod(String cp, String modName) {
! int rc = JMOD_TOOL.run(System.out, System.out, new String[] {
"create",
"--class-path", cp,
"--module-version", "1.0",
"--main-class", "jdk.test.Test",
jmods.resolve(modName + ".jmod").toString(),
! });
if (rc != 0) {
throw new AssertionError("Jmod failed: rc = " + rc);
}
}
}
< prev index next >