test/hotspot/jtreg/runtime/appcds/JarBuilder.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File
*** old/test/hotspot/jtreg/runtime/appcds/JarBuilder.java	Mon Apr  9 12:06:48 2018
--- new/test/hotspot/jtreg/runtime/appcds/JarBuilder.java	Mon Apr  9 12:06:48 2018

*** 1,7 **** --- 1,7 ---- /* ! * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. ! * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 30,42 **** --- 30,44 ---- * Output: A jar containing compiled classes, placed in a test classes folder * @library /open/test/lib */ import jdk.test.lib.JDKToolFinder; + import jdk.test.lib.compiler.CompilerUtils; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; import java.io.File; + import java.nio.file.Path; import java.util.ArrayList; import sun.tools.jar.Main; public class JarBuilder { // to turn DEBUG on via command line: -DJarBuilder.DEBUG=[true, TRUE]
*** 143,152 **** --- 145,169 ---- args.add(jarclassDir); args.add(name + ".class"); } } + public static void createModularJar(String jarPath, + String classesDir, + String mainClass) throws Exception { + ArrayList<String> argList = new ArrayList<String>(); + argList.add("--create"); + argList.add("--file=" + jarPath); + if (mainClass != null) { + argList.add("--main-class=" + mainClass); + } + argList.add("-C"); + argList.add(classesDir); + argList.add("."); + createJar(argList); + } + private static void createJar(ArrayList<String> args) { if (DEBUG) printIterable("createJar args: ", args); Main jarTool = new Main(System.out, System.err, "jar"); if (!jarTool.run(args.toArray(new String[1]))) {
*** 188,197 **** --- 205,231 ---- ProcessBuilder pb = new ProcessBuilder(args); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); } + public static void compileModule(Path src, + Path dest, + String modulePathArg // arg to --module-path + ) throws Exception { + boolean compiled = false; + if (modulePathArg == null) { + compiled = CompilerUtils.compile(src, dest); + } else { + compiled = CompilerUtils.compile(src, dest, + "--module-path", modulePathArg); + } + if (!compiled) { + throw new RuntimeException("module did not compile"); + } + } + + public static void signJar() throws Exception { String keyTool = JDKToolFinder.getJDKTool("keytool"); String jarSigner = JDKToolFinder.getJDKTool("jarsigner"); String classDir = System.getProperty("test.classes"); String FS = File.separator;

test/hotspot/jtreg/runtime/appcds/JarBuilder.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File