23
24 import java.nio.file.Files;
25 import java.nio.file.Path;
26 import java.util.List;
27 import java.util.jar.JarEntry;
28 import java.util.jar.JarOutputStream;
29 import java.util.spi.ToolProvider;
30
31 import jdk.test.lib.JDKToolFinder;
32 import jdk.test.lib.process.OutputAnalyzer;
33 import jdk.test.lib.process.ProcessTools;
34 import org.junit.jupiter.api.Test;
35 import static java.nio.charset.StandardCharsets.US_ASCII;
36 import static org.junit.jupiter.api.Assertions.assertEquals;
37 import static org.junit.jupiter.api.Assertions.assertTrue;
38
39 /*
40 * @test
41 * @bug 8154212 8154470 8392966
42 * @summary Miscellaneous tests for java launcher
43 * @library /test/lib
44 * @build jdk.test.lib.process.ProcessTools jdk.test.lib.JDKToolFinder
45 * jdk.test.lib.process.OutputAnalyzer
46 * @run junit ${test.main.class}
47 */
48 public class MiscTests {
49
50 private static final ToolProvider JAVAC = ToolProvider.findFirst("javac")
51 .orElseThrow(() -> new RuntimeException("javac not found"));
52
53 /**
54 * Launch "java" with class path set on the command line via -Djava.class.path
55 * and verify that the launcher correctly launches the main application
56 */
57 @Test
58 void testWithClassPathSetViaProperty() throws Exception {
59 final String mainClass = "Foo";
60 // create the .java file
61 final Path sourceFile = Path.of(mainClass + ".java");
62 final String content = """
|
23
24 import java.nio.file.Files;
25 import java.nio.file.Path;
26 import java.util.List;
27 import java.util.jar.JarEntry;
28 import java.util.jar.JarOutputStream;
29 import java.util.spi.ToolProvider;
30
31 import jdk.test.lib.JDKToolFinder;
32 import jdk.test.lib.process.OutputAnalyzer;
33 import jdk.test.lib.process.ProcessTools;
34 import org.junit.jupiter.api.Test;
35 import static java.nio.charset.StandardCharsets.US_ASCII;
36 import static org.junit.jupiter.api.Assertions.assertEquals;
37 import static org.junit.jupiter.api.Assertions.assertTrue;
38
39 /*
40 * @test
41 * @bug 8154212 8154470 8392966
42 * @summary Miscellaneous tests for java launcher
43 * @requires test.thread.factory != "Virtual"
44 * @library /test/lib
45 * @build jdk.test.lib.process.ProcessTools jdk.test.lib.JDKToolFinder
46 * jdk.test.lib.process.OutputAnalyzer
47 * @run junit ${test.main.class}
48 */
49 public class MiscTests {
50
51 private static final ToolProvider JAVAC = ToolProvider.findFirst("javac")
52 .orElseThrow(() -> new RuntimeException("javac not found"));
53
54 /**
55 * Launch "java" with class path set on the command line via -Djava.class.path
56 * and verify that the launcher correctly launches the main application
57 */
58 @Test
59 void testWithClassPathSetViaProperty() throws Exception {
60 final String mainClass = "Foo";
61 // create the .java file
62 final Path sourceFile = Path.of(mainClass + ".java");
63 final String content = """
|