jdk/test/tools/lib/tests/JImageGenerator.java
changeset 41484 834b7539ada3
parent 41212 54a8bb41b174
equal deleted inserted replaced
41483:99e81f03a628 41484:834b7539ada3
   336             throw new AssertionError("Module check failed.");
   336             throw new AssertionError("Module check failed.");
   337         }
   337         }
   338     }
   338     }
   339 
   339 
   340     public static class JModTask {
   340     public static class JModTask {
       
   341         static final java.util.spi.ToolProvider JMOD_TOOL =
       
   342             java.util.spi.ToolProvider.findFirst("jmod").orElseThrow(() ->
       
   343                 new RuntimeException("jmod tool not found")
       
   344             );
   341 
   345 
   342         private final List<Path> classpath = new ArrayList<>();
   346         private final List<Path> classpath = new ArrayList<>();
   343         private final List<Path> libs = new ArrayList<>();
   347         private final List<Path> libs = new ArrayList<>();
   344         private final List<Path> cmds = new ArrayList<>();
   348         private final List<Path> cmds = new ArrayList<>();
   345         private final List<Path> config = new ArrayList<>();
   349         private final List<Path> config = new ArrayList<>();
   475 
   479 
   476         private Result cmd(String cmd) {
   480         private Result cmd(String cmd) {
   477             String[] args = optionsJMod(cmd);
   481             String[] args = optionsJMod(cmd);
   478             System.err.println("jmod options: " + optionsPrettyPrint(args));
   482             System.err.println("jmod options: " + optionsPrettyPrint(args));
   479             ByteArrayOutputStream baos = new ByteArrayOutputStream();
   483             ByteArrayOutputStream baos = new ByteArrayOutputStream();
   480             int exitCode = jdk.tools.jmod.Main.run(args, new PrintStream(baos));
   484             PrintStream ps = new PrintStream(baos);
       
   485             int exitCode = JMOD_TOOL.run(ps, ps, args);
   481             String msg = new String(baos.toByteArray());
   486             String msg = new String(baos.toByteArray());
   482             return new Result(exitCode, msg, output);
   487             return new Result(exitCode, msg, output);
   483         }
   488         }
   484     }
   489     }
   485 
   490 
   554             return cmd("extract", dir);
   559             return cmd("extract", dir);
   555         }
   560         }
   556     }
   561     }
   557 
   562 
   558     public static class JLinkTask {
   563     public static class JLinkTask {
       
   564         static final java.util.spi.ToolProvider JLINK_TOOL =
       
   565             java.util.spi.ToolProvider.findFirst("jlink").orElseThrow(() ->
       
   566                 new RuntimeException("jlink tool not found")
       
   567             );
   559 
   568 
   560         private final List<Path> jars = new ArrayList<>();
   569         private final List<Path> jars = new ArrayList<>();
   561         private final List<Path> jmods = new ArrayList<>();
   570         private final List<Path> jmods = new ArrayList<>();
   562         private final List<Path> pluginModulePath = new ArrayList<>();
   571         private final List<Path> pluginModulePath = new ArrayList<>();
   563         private final List<String> addMods = new ArrayList<>();
   572         private final List<String> addMods = new ArrayList<>();
   689 
   698 
   690         public Result call() {
   699         public Result call() {
   691             String[] args = optionsJLink();
   700             String[] args = optionsJLink();
   692             System.err.println("jlink options: " + optionsPrettyPrint(args));
   701             System.err.println("jlink options: " + optionsPrettyPrint(args));
   693             StringWriter writer = new StringWriter();
   702             StringWriter writer = new StringWriter();
   694             int exitCode = jdk.tools.jlink.internal.Main.run(args, new PrintWriter(writer));
   703             PrintWriter pw = new PrintWriter(writer);
       
   704             int exitCode = JLINK_TOOL.run(pw, pw, args);
   695             return new Result(exitCode, writer.toString(), output);
   705             return new Result(exitCode, writer.toString(), output);
   696         }
   706         }
   697 
   707 
   698         public Result callPostProcess() {
   708         public Result callPostProcess() {
   699             String[] args = optionsPostProcessJLink();
   709             String[] args = optionsPostProcessJLink();
   700             System.err.println("jlink options: " + optionsPrettyPrint(args));
   710             System.err.println("jlink options: " + optionsPrettyPrint(args));
   701             StringWriter writer = new StringWriter();
   711             StringWriter writer = new StringWriter();
   702             int exitCode = jdk.tools.jlink.internal.Main.run(args, new PrintWriter(writer));
   712             PrintWriter pw = new PrintWriter(writer);
       
   713             int exitCode = JLINK_TOOL.run(pw, pw, args);
   703             return new Result(exitCode, writer.toString(), output);
   714             return new Result(exitCode, writer.toString(), output);
   704         }
   715         }
   705     }
   716     }
   706 
   717 
   707     public static class InMemorySourceFile {
   718     public static class InMemorySourceFile {