< prev index next >

jdk/test/tools/jmod/JmodTest.java

Print this page

        

@@ -22,12 +22,12 @@
  */
 
 /*
  * @test
  * @library /lib/testlibrary
- * @modules jdk.jlink/jdk.tools.jmod
- *          jdk.compiler
+ * @modules jdk.compiler
+ *          jdk.jlink
  * @build jdk.testlibrary.FileUtils CompilerUtils
  * @run testng JmodTest
  * @summary Basic test for jmod
  */
 

@@ -36,10 +36,11 @@
 import java.lang.reflect.Method;
 import java.nio.file.*;
 import java.util.*;
 import java.util.function.Consumer;
 import java.util.regex.Pattern;
+import java.util.spi.ToolProvider;
 import java.util.stream.Stream;
 import jdk.testlibrary.FileUtils;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 

@@ -49,10 +50,15 @@
 import static java.util.stream.Collectors.toSet;
 import static org.testng.Assert.*;
 
 public class JmodTest {
 
+    static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod")
+        .orElseThrow(() ->
+            new RuntimeException("jmod tool not found")
+        );
+
     static final String TEST_SRC = System.getProperty("test.src", ".");
     static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
     static final Path EXPLODED_DIR = Paths.get("build");
     static final Path MODS_DIR = Paths.get("jmods");
 

@@ -477,11 +483,11 @@
 
     static JmodResult jmod(String... args) {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         PrintStream ps = new PrintStream(baos);
         System.out.println("jmod " + Arrays.asList(args));
-        int ec = jdk.tools.jmod.Main.run(args, ps);
+        int ec = JMOD_TOOL.run(ps, ps, args);
         return new JmodResult(ec, new String(baos.toByteArray(), UTF_8));
     }
 
     static class JmodResult {
         final int exitCode;
< prev index next >