8319567: Update java/lang/invoke tests to support vm flags
8319568: Update java/lang/reflect/exeCallerAccessTest/CallerAccessTest.java to accept vm flags 8319672: Several classloader tests ignore VM flags 8319676: A couple of jdk/modules/incubator/ tests ignore VM flags 8319677: Test jdk/internal/misc/VM/RuntimeArguments.java should be marked as flagless Reviewed-by: jvernee, lmesnik
This commit is contained in:
parent
9727f4bddd
commit
1588dd934c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,6 +24,8 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 4290640 4785473
|
* @bug 4290640 4785473
|
||||||
|
* @requires vm.flagless
|
||||||
|
* @library /test/lib
|
||||||
* @build package1.Class1 package2.Class2 package1.package3.Class3 Assert
|
* @build package1.Class1 package2.Class2 package1.package3.Class3 Assert
|
||||||
* @run main/othervm Assert
|
* @run main/othervm Assert
|
||||||
* @summary Test the assertion facility
|
* @summary Test the assertion facility
|
||||||
@ -31,12 +33,17 @@
|
|||||||
* @key randomness
|
* @key randomness
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
import package1.*;
|
import package1.*;
|
||||||
import package2.*;
|
import package2.*;
|
||||||
import package1.package3.*;
|
import package1.package3.*;
|
||||||
import java.io.*;
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import static jdk.test.lib.process.ProcessTools.*;
|
||||||
|
|
||||||
public class Assert {
|
public class Assert {
|
||||||
|
|
||||||
private static Class1 testClass1;
|
private static Class1 testClass1;
|
||||||
@ -56,7 +63,7 @@ public class Assert {
|
|||||||
* off at class load time. Once the class is loaded its assertion status
|
* off at class load time. Once the class is loaded its assertion status
|
||||||
* does not change.
|
* does not change.
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Throwable {
|
||||||
|
|
||||||
// Switch values: 0=don't touch, 1=off, 2 = on
|
// Switch values: 0=don't touch, 1=off, 2 = on
|
||||||
int[] switches = new int[7];
|
int[] switches = new int[7];
|
||||||
@ -77,28 +84,17 @@ public class Assert {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Spawn new VM and load classes
|
// Spawn new VM and load classes
|
||||||
String command = System.getProperty("java.home") +
|
List<String> commands = new ArrayList<>();
|
||||||
File.separator + "bin" + File.separator + "java Assert";
|
commands.add("Assert");
|
||||||
|
|
||||||
StringBuffer commandString = new StringBuffer(command);
|
|
||||||
for(int j=0; j<7; j++)
|
for(int j=0; j<7; j++)
|
||||||
commandString.append(" "+switches[j]);
|
commands.add(Integer.toString(switches[j]));
|
||||||
|
OutputAnalyzer outputAnalyzer = executeCommand(createLimitedTestJavaProcessBuilder(commands));
|
||||||
Process p = null;
|
|
||||||
p = Runtime.getRuntime().exec(commandString.toString());
|
|
||||||
|
|
||||||
if (debug) { // See output of test VMs
|
if (debug) { // See output of test VMs
|
||||||
BufferedReader blah = new BufferedReader(
|
outputAnalyzer.asLines()
|
||||||
new InputStreamReader(p.getInputStream()));
|
.stream()
|
||||||
String outString = blah.readLine();
|
.forEach(s -> System.out.println(s));
|
||||||
while (outString != null) {
|
|
||||||
System.out.println("from BufferedReader:"+outString);
|
|
||||||
outString = blah.readLine();
|
|
||||||
}
|
}
|
||||||
}
|
int result = outputAnalyzer.getExitValue();
|
||||||
|
|
||||||
p.waitFor();
|
|
||||||
int result = p.exitValue();
|
|
||||||
if (debug) { // See which switch configs failed
|
if (debug) { // See which switch configs failed
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
for(int k=6; k>=0; k--)
|
for(int k=6; k>=0; k--)
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8060130
|
* @bug 8060130
|
||||||
|
* @requires vm.flagless
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @build package2.Class2 GetSystemPackage
|
* @build package2.Class2 GetSystemPackage
|
||||||
* @summary Test if getSystemPackage() return consistent values for cases
|
* @summary Test if getSystemPackage() return consistent values for cases
|
||||||
@ -41,6 +42,8 @@ import java.util.jar.Attributes;
|
|||||||
import java.util.jar.JarEntry;
|
import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarOutputStream;
|
import java.util.jar.JarOutputStream;
|
||||||
import java.util.jar.Manifest;
|
import java.util.jar.Manifest;
|
||||||
|
|
||||||
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
import jdk.test.lib.process.ProcessTools;
|
import jdk.test.lib.process.ProcessTools;
|
||||||
|
|
||||||
public class GetSystemPackage {
|
public class GetSystemPackage {
|
||||||
@ -118,8 +121,9 @@ public class GetSystemPackage {
|
|||||||
private static void runSubProcess(String messageOnError, String ... args)
|
private static void runSubProcess(String messageOnError, String ... args)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args);
|
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args)
|
||||||
int res = pb.directory(tmpFolder).inheritIO().start().waitFor();
|
.directory(tmpFolder);
|
||||||
|
int res = ProcessTools.executeProcess(pb).getExitValue();
|
||||||
if (res != 0) {
|
if (res != 0) {
|
||||||
throw new RuntimeException(messageOnError);
|
throw new RuntimeException(messageOnError);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -40,11 +40,9 @@ import java.nio.file.Path;
|
|||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import jdk.test.lib.JDKToolFinder;
|
|
||||||
import static jdk.test.lib.process.ProcessTools.*;
|
import static jdk.test.lib.process.ProcessTools.*;
|
||||||
|
|
||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeTest;
|
||||||
@ -144,26 +142,14 @@ public class GetResource {
|
|||||||
private void runTest(Path dir, List<String> options, String expected)
|
private void runTest(Path dir, List<String> options, String expected)
|
||||||
throws Throwable
|
throws Throwable
|
||||||
{
|
{
|
||||||
String javapath = JDKToolFinder.getJDKTool("java");
|
|
||||||
|
|
||||||
List<String> cmdLine = new ArrayList<>();
|
List<String> cmdLine = new ArrayList<>();
|
||||||
cmdLine.add(javapath);
|
|
||||||
options.forEach(cmdLine::add);
|
options.forEach(cmdLine::add);
|
||||||
|
|
||||||
cmdLine.add("GetResource");
|
cmdLine.add("GetResource");
|
||||||
cmdLine.add(expected);
|
cmdLine.add(expected);
|
||||||
|
ProcessBuilder pb = createTestJavaProcessBuilder(cmdLine);
|
||||||
System.out.println("Command line: " + cmdLine);
|
pb.directory(dir.toFile()); // change working directory
|
||||||
ProcessBuilder pb =
|
pb.environment().remove("CLASSPATH"); // remove CLASSPATH environment variable
|
||||||
new ProcessBuilder(cmdLine.stream().toArray(String[]::new));
|
|
||||||
|
|
||||||
// change working directory
|
|
||||||
pb.directory(dir.toFile());
|
|
||||||
|
|
||||||
// remove CLASSPATH environment variable
|
|
||||||
Map<String,String> env = pb.environment();
|
|
||||||
String value = env.remove("CLASSPATH");
|
|
||||||
|
|
||||||
executeCommand(pb).shouldHaveExitValue(0);
|
executeCommand(pb).shouldHaveExitValue(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2021, BELLSOFT. All rights reserved.
|
* Copyright (c) 2021, BELLSOFT. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
@ -38,31 +38,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import jdk.test.lib.Asserts;
|
import jdk.test.lib.Asserts;
|
||||||
import jdk.test.lib.JDKToolFinder;
|
|
||||||
import jdk.test.lib.process.OutputAnalyzer;
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
|
|
||||||
import java.lang.ProcessBuilder;
|
import static jdk.test.lib.process.ProcessTools.*;
|
||||||
import java.lang.Process;
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class LoadLibraryUnloadTest {
|
public class LoadLibraryUnloadTest {
|
||||||
|
|
||||||
private static String testClassPath = System.getProperty("test.classes");
|
private static String testClassPath = System.getProperty("test.classes");
|
||||||
private static String testLibraryPath = System.getProperty("test.nativepath");
|
private static String testLibraryPath = System.getProperty("test.nativepath");
|
||||||
|
|
||||||
private static Process runJavaCommand(String... command) throws Throwable {
|
|
||||||
String java = JDKToolFinder.getJDKTool("java");
|
|
||||||
List<String> commands = new ArrayList<>();
|
|
||||||
Collections.addAll(commands, java);
|
|
||||||
Collections.addAll(commands, command);
|
|
||||||
System.out.println("COMMAND: " + String.join(" ", commands));
|
|
||||||
return new ProcessBuilder(commands.toArray(new String[0]))
|
|
||||||
.redirectErrorStream(true)
|
|
||||||
.directory(new File(testClassPath))
|
|
||||||
.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static long countLines(OutputAnalyzer output, String string) {
|
private final static long countLines(OutputAnalyzer output, String string) {
|
||||||
return output.asLines()
|
return output.asLines()
|
||||||
.stream()
|
.stream()
|
||||||
@ -78,12 +62,10 @@ public class LoadLibraryUnloadTest {
|
|||||||
|
|
||||||
public static void main(String[] args) throws Throwable {
|
public static void main(String[] args) throws Throwable {
|
||||||
|
|
||||||
Process process = runJavaCommand(
|
OutputAnalyzer outputAnalyzer = executeCommand(createTestJavaProcessBuilder(
|
||||||
"-Dtest.classes=" + testClassPath,
|
"-Dtest.classes=" + testClassPath,
|
||||||
"-Djava.library.path=" + testLibraryPath,
|
"-Djava.library.path=" + testLibraryPath,
|
||||||
"LoadLibraryUnload");
|
"LoadLibraryUnload"));
|
||||||
|
|
||||||
OutputAnalyzer outputAnalyzer = new OutputAnalyzer(process);
|
|
||||||
dump(outputAnalyzer);
|
dump(outputAnalyzer);
|
||||||
|
|
||||||
Asserts.assertTrue(
|
Asserts.assertTrue(
|
||||||
|
@ -44,7 +44,7 @@ import jdk.test.lib.compiler.InMemoryJavaCompiler;
|
|||||||
*/
|
*/
|
||||||
public class CondyNestedResolutionTest {
|
public class CondyNestedResolutionTest {
|
||||||
public static void main(String args[]) throws Throwable {
|
public static void main(String args[]) throws Throwable {
|
||||||
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("CondyNestedResolution");
|
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("CondyNestedResolution");
|
||||||
OutputAnalyzer oa = new OutputAnalyzer(pb.start());
|
OutputAnalyzer oa = new OutputAnalyzer(pb.start());
|
||||||
oa.shouldContain("StackOverflowError");
|
oa.shouldContain("StackOverflowError");
|
||||||
oa.shouldContain("bsm1arg");
|
oa.shouldContain("bsm1arg");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -37,13 +37,11 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import jdk.test.lib.JDKToolFinder;
|
import static jdk.test.lib.process.ProcessTools.*;
|
||||||
import jdk.test.lib.process.ProcessTools;
|
|
||||||
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
public class FindSpecialTest {
|
public class FindSpecialTest {
|
||||||
static final String JAVA_LAUNCHER = JDKToolFinder.getJDKTool("java");
|
|
||||||
static final String TEST_CLASSES = System.getProperty("test.classes", ".");
|
static final String TEST_CLASSES = System.getProperty("test.classes", ".");
|
||||||
static final String TEST_CLASS_PATH = System.getProperty("test.class.path");
|
static final String TEST_CLASS_PATH = System.getProperty("test.class.path");
|
||||||
static final String TEST_MAIN_CLASS = "test.FindSpecial";
|
static final String TEST_MAIN_CLASS = "test.FindSpecial";
|
||||||
@ -59,7 +57,8 @@ public class FindSpecialTest {
|
|||||||
throw new Error(m1 + " not exist");
|
throw new Error(m1 + " not exist");
|
||||||
}
|
}
|
||||||
String classpath = m1.toString() + File.pathSeparator + TEST_CLASS_PATH;
|
String classpath = m1.toString() + File.pathSeparator + TEST_CLASS_PATH;
|
||||||
ProcessTools.executeCommand(JAVA_LAUNCHER, "-cp", classpath, TEST_MAIN_CLASS)
|
executeCommand(createTestJavaProcessBuilder("-cp", classpath,
|
||||||
|
TEST_MAIN_CLASS))
|
||||||
.shouldHaveExitValue(0);
|
.shouldHaveExitValue(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,10 +71,9 @@ public class FindSpecialTest {
|
|||||||
if (Files.notExists(modules)) {
|
if (Files.notExists(modules)) {
|
||||||
throw new Error(modules + " not exist");
|
throw new Error(modules + " not exist");
|
||||||
}
|
}
|
||||||
ProcessTools.executeCommand(JAVA_LAUNCHER,
|
executeCommand(createTestJavaProcessBuilder("-cp", TEST_CLASS_PATH,
|
||||||
"-cp", TEST_CLASS_PATH,
|
|
||||||
"-p", modules.toString(),
|
"-p", modules.toString(),
|
||||||
"-m", TEST_MODULE + "/" + TEST_MAIN_CLASS)
|
"-m", TEST_MODULE + "/" + TEST_MAIN_CLASS))
|
||||||
.shouldHaveExitValue(0);
|
.shouldHaveExitValue(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,171 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2012, 2013, 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.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* support infrastructure to invoke a java class from the command line
|
|
||||||
*/
|
|
||||||
class LUtils {
|
|
||||||
static final com.sun.tools.javac.Main javac =
|
|
||||||
new com.sun.tools.javac.Main();
|
|
||||||
static final File cwd = new File(".").getAbsoluteFile();
|
|
||||||
static final String JAVAHOME = System.getProperty("java.home");
|
|
||||||
static final boolean isWindows =
|
|
||||||
System.getProperty("os.name", "unknown").startsWith("Windows");
|
|
||||||
static final File JAVA_BIN_FILE = new File(JAVAHOME, "bin");
|
|
||||||
static final File JAVA_CMD = new File(JAVA_BIN_FILE,
|
|
||||||
isWindows ? "java.exe" : "java");
|
|
||||||
static final File JAR_BIN_FILE = new File(JAVAHOME, "bin");
|
|
||||||
static final File JAR_CMD = new File(JAR_BIN_FILE,
|
|
||||||
isWindows ? "jar.exe" : "jar");
|
|
||||||
|
|
||||||
protected LUtils() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void compile(String... args) {
|
|
||||||
if (javac.compile(args) != 0) {
|
|
||||||
throw new RuntimeException("compilation fails");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void createFile(File outFile, List<String> content) {
|
|
||||||
try {
|
|
||||||
Files.write(outFile.getAbsoluteFile().toPath(), content,
|
|
||||||
Charset.defaultCharset());
|
|
||||||
} catch (IOException ex) {
|
|
||||||
throw new RuntimeException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static File getClassFile(File javaFile) {
|
|
||||||
return javaFile.getName().endsWith(".java")
|
|
||||||
? new File(javaFile.getName().replace(".java", ".class"))
|
|
||||||
: null;
|
|
||||||
}
|
|
||||||
|
|
||||||
static String getSimpleName(File inFile) {
|
|
||||||
String fname = inFile.getName();
|
|
||||||
return fname.substring(0, fname.indexOf("."));
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult doExec(String... cmds) {
|
|
||||||
return doExec(null, null, cmds);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* A method which executes a java cmd and returns the results in a container
|
|
||||||
*/
|
|
||||||
static TestResult doExec(Map<String, String> envToSet,
|
|
||||||
java.util.Set<String> envToRemove, String... cmds) {
|
|
||||||
String cmdStr = "";
|
|
||||||
for (String x : cmds) {
|
|
||||||
cmdStr = cmdStr.concat(x + " ");
|
|
||||||
}
|
|
||||||
ProcessBuilder pb = new ProcessBuilder(cmds);
|
|
||||||
Map<String, String> env = pb.environment();
|
|
||||||
if (envToRemove != null) {
|
|
||||||
for (String key : envToRemove) {
|
|
||||||
env.remove(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (envToSet != null) {
|
|
||||||
env.putAll(envToSet);
|
|
||||||
}
|
|
||||||
BufferedReader rdr = null;
|
|
||||||
try {
|
|
||||||
List<String> outputList = new ArrayList<>();
|
|
||||||
pb.redirectErrorStream(true);
|
|
||||||
Process p = pb.start();
|
|
||||||
rdr = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
|
||||||
String in = rdr.readLine();
|
|
||||||
while (in != null) {
|
|
||||||
outputList.add(in);
|
|
||||||
in = rdr.readLine();
|
|
||||||
}
|
|
||||||
p.waitFor();
|
|
||||||
p.destroy();
|
|
||||||
|
|
||||||
return new TestResult(cmdStr, p.exitValue(), outputList,
|
|
||||||
env, new Throwable("current stack of the test"));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
throw new RuntimeException(ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static class TestResult {
|
|
||||||
String cmd;
|
|
||||||
int exitValue;
|
|
||||||
List<String> testOutput;
|
|
||||||
Map<String, String> env;
|
|
||||||
Throwable t;
|
|
||||||
|
|
||||||
public TestResult(String str, int rv, List<String> oList,
|
|
||||||
Map<String, String> env, Throwable t) {
|
|
||||||
cmd = str;
|
|
||||||
exitValue = rv;
|
|
||||||
testOutput = oList;
|
|
||||||
this.env = env;
|
|
||||||
this.t = t;
|
|
||||||
}
|
|
||||||
|
|
||||||
void assertZero(String message) {
|
|
||||||
if (exitValue != 0) {
|
|
||||||
System.err.println(this);
|
|
||||||
throw new RuntimeException(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringWriter sw = new StringWriter();
|
|
||||||
PrintWriter status = new PrintWriter(sw);
|
|
||||||
status.println("Cmd: " + cmd);
|
|
||||||
status.println("Return code: " + exitValue);
|
|
||||||
status.println("Environment variable:");
|
|
||||||
for (String x : env.keySet()) {
|
|
||||||
status.println("\t" + x + "=" + env.get(x));
|
|
||||||
}
|
|
||||||
status.println("Output:");
|
|
||||||
for (String x : testOutput) {
|
|
||||||
status.println("\t" + x);
|
|
||||||
}
|
|
||||||
status.println("Exception:");
|
|
||||||
status.println(t.getMessage());
|
|
||||||
t.printStackTrace(status);
|
|
||||||
|
|
||||||
return sw.getBuffer().toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,19 +24,28 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8003881
|
* @bug 8003881
|
||||||
* @summary tests DoPrivileged action (implemented as lambda expressions) by
|
* @library /test/lib/
|
||||||
* inserting them into the BootClassPath.
|
|
||||||
* @modules jdk.compiler
|
* @modules jdk.compiler
|
||||||
* jdk.zipfs
|
* jdk.zipfs
|
||||||
* @compile -XDignore.symbol.file LambdaAccessControlDoPrivilegedTest.java LUtils.java
|
* @compile LambdaAccessControlDoPrivilegedTest.java
|
||||||
* @run main/othervm -Djava.security.manager=allow LambdaAccessControlDoPrivilegedTest
|
* @run main/othervm -Djava.security.manager=allow LambdaAccessControlDoPrivilegedTest
|
||||||
|
* @summary tests DoPrivileged action (implemented as lambda expressions) by
|
||||||
|
* inserting them into the BootClassPath.
|
||||||
*/
|
*/
|
||||||
import java.io.File;
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.spi.ToolProvider;
|
||||||
|
|
||||||
public class LambdaAccessControlDoPrivilegedTest extends LUtils {
|
import static jdk.test.lib.process.ProcessTools.*;
|
||||||
public static void main(String... args) {
|
|
||||||
|
public class LambdaAccessControlDoPrivilegedTest {
|
||||||
|
public static void main(String... args) throws Exception {
|
||||||
final List<String> scratch = new ArrayList();
|
final List<String> scratch = new ArrayList();
|
||||||
scratch.clear();
|
scratch.clear();
|
||||||
scratch.add("import java.security.*;");
|
scratch.add("import java.security.*;");
|
||||||
@ -47,9 +56,9 @@ public class LambdaAccessControlDoPrivilegedTest extends LUtils {
|
|||||||
scratch.add("});");
|
scratch.add("});");
|
||||||
scratch.add("}");
|
scratch.add("}");
|
||||||
scratch.add("}");
|
scratch.add("}");
|
||||||
File doprivJava = new File("DoPriv.java");
|
Path doprivJava = Path.of("DoPriv.java");
|
||||||
File doprivClass = getClassFile(doprivJava);
|
Path doprivClass = Path.of("DoPriv.class");
|
||||||
createFile(doprivJava, scratch);
|
Files.write(doprivJava, scratch, Charset.defaultCharset());
|
||||||
|
|
||||||
scratch.clear();
|
scratch.clear();
|
||||||
scratch.add("public class Bar {");
|
scratch.add("public class Bar {");
|
||||||
@ -59,30 +68,40 @@ public class LambdaAccessControlDoPrivilegedTest extends LUtils {
|
|||||||
scratch.add("}");
|
scratch.add("}");
|
||||||
scratch.add("}");
|
scratch.add("}");
|
||||||
|
|
||||||
File barJava = new File("Bar.java");
|
Path barJava = Path.of("Bar.java");
|
||||||
File barClass = getClassFile(barJava);
|
Path barClass = Path.of("Bar.class");
|
||||||
createFile(barJava, scratch);
|
Files.write(barJava, scratch, Charset.defaultCharset());
|
||||||
|
|
||||||
String[] javacArgs = {barJava.getName(), doprivJava.getName()};
|
compile(barJava.toString(), doprivJava.toString());
|
||||||
compile(javacArgs);
|
|
||||||
File jarFile = new File("foo.jar");
|
jar("cvf", "foo.jar", doprivClass.toString());
|
||||||
String[] jargs = {"cvf", jarFile.getName(), doprivClass.getName()};
|
Files.delete(doprivJava);
|
||||||
TestResult tr = doExec(JAR_CMD.getAbsolutePath(),
|
Files.delete(doprivClass);
|
||||||
"cvf", jarFile.getName(),
|
|
||||||
doprivClass.getName());
|
ProcessBuilder pb = createTestJavaProcessBuilder(
|
||||||
if (tr.exitValue != 0){
|
|
||||||
throw new RuntimeException(tr.toString());
|
|
||||||
}
|
|
||||||
doprivJava.delete();
|
|
||||||
doprivClass.delete();
|
|
||||||
tr = doExec(JAVA_CMD.getAbsolutePath(),
|
|
||||||
"-Xbootclasspath/a:foo.jar",
|
"-Xbootclasspath/a:foo.jar",
|
||||||
"-cp", ".",
|
"-cp", ".",
|
||||||
"-Djava.security.manager=allow",
|
"-Djava.security.manager=allow",
|
||||||
"Bar");
|
"Bar");
|
||||||
tr.assertZero("testDoPrivileged fails");
|
executeProcess(pb).shouldHaveExitValue(0);
|
||||||
barJava.delete();
|
|
||||||
barClass.delete();
|
Files.delete(barJava);
|
||||||
jarFile.delete();
|
Files.delete(barClass);
|
||||||
|
Files.delete(Path.of("foo.jar"));
|
||||||
|
}
|
||||||
|
|
||||||
|
static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar").orElseThrow();
|
||||||
|
static final ToolProvider JAVAC = ToolProvider.findFirst("javac").orElseThrow();
|
||||||
|
static void compile(String... args) throws IOException {
|
||||||
|
if (JAVAC.run(System.out, System.err, args) != 0) {
|
||||||
|
throw new RuntimeException("compilation fails");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void jar(String... args) {
|
||||||
|
int rc = JAR_TOOL.run(System.out, System.err, args);
|
||||||
|
if (rc != 0){
|
||||||
|
throw new RuntimeException("fail to create JAR file");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,14 +24,12 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8003881
|
* @bug 8003881
|
||||||
* @summary tests Lambda expression with a security manager at top level
|
|
||||||
* @modules jdk.compiler
|
* @modules jdk.compiler
|
||||||
* @compile -XDignore.symbol.file LambdaAccessControlTest.java LUtils.java
|
|
||||||
*
|
|
||||||
* @run main/othervm -Djava.security.manager=allow LambdaAccessControlTest
|
* @run main/othervm -Djava.security.manager=allow LambdaAccessControlTest
|
||||||
|
* @summary tests Lambda expression with a security manager at top level
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class LambdaAccessControlTest extends LUtils {
|
public class LambdaAccessControlTest {
|
||||||
public static void main(String... args) {
|
public static void main(String... args) {
|
||||||
System.setSecurityManager(new SecurityManager());
|
System.setSecurityManager(new SecurityManager());
|
||||||
JJ<Integer> iii = (new CC())::impl;
|
JJ<Integer> iii = (new CC())::impl;
|
||||||
|
@ -24,13 +24,14 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8027232
|
* @bug 8027232
|
||||||
* @summary ensures that j.l.i.InvokerByteCodeGenerator and ASM visitMethodInsn
|
* @library /test/lib/
|
||||||
* generate bytecodes with correct constant pool references
|
|
||||||
* @modules java.base/jdk.internal.org.objectweb.asm
|
* @modules java.base/jdk.internal.org.objectweb.asm
|
||||||
* jdk.jdeps/com.sun.tools.classfile
|
* jdk.jdeps/com.sun.tools.classfile
|
||||||
* jdk.zipfs
|
* jdk.zipfs
|
||||||
* @compile -XDignore.symbol.file LambdaAsm.java LUtils.java
|
* @compile LambdaAsm.java
|
||||||
* @run main/othervm LambdaAsm
|
* @run main/othervm LambdaAsm
|
||||||
|
* @summary ensures that j.l.i.InvokerByteCodeGenerator and ASM visitMethodInsn
|
||||||
|
* generate bytecodes with correct constant pool references
|
||||||
*/
|
*/
|
||||||
import com.sun.tools.classfile.Attribute;
|
import com.sun.tools.classfile.Attribute;
|
||||||
import com.sun.tools.classfile.ClassFile;
|
import com.sun.tools.classfile.ClassFile;
|
||||||
@ -40,34 +41,36 @@ import com.sun.tools.classfile.ConstantPool.CPInfo;
|
|||||||
import com.sun.tools.classfile.Instruction;
|
import com.sun.tools.classfile.Instruction;
|
||||||
import com.sun.tools.classfile.Method;
|
import com.sun.tools.classfile.Method;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.nio.file.DirectoryStream;
|
import java.nio.file.DirectoryStream;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import jdk.internal.org.objectweb.asm.ClassWriter;
|
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||||
import jdk.internal.org.objectweb.asm.MethodVisitor;
|
import jdk.internal.org.objectweb.asm.MethodVisitor;
|
||||||
|
import jdk.test.lib.compiler.CompilerUtils;
|
||||||
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
|
|
||||||
import static java.nio.file.Files.*;
|
import static java.nio.file.Files.*;
|
||||||
import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||||
|
import static jdk.test.lib.process.ProcessTools.*;
|
||||||
|
|
||||||
public class LambdaAsm {
|
public class LambdaAsm {
|
||||||
static final Path DUMP_LAMBDA_PROXY_CLASS_FILES = Path.of("DUMP_LAMBDA_PROXY_CLASS_FILES");
|
static final Path DUMP_LAMBDA_PROXY_CLASS_FILES = Path.of("DUMP_LAMBDA_PROXY_CLASS_FILES");
|
||||||
|
static final Path SRC = Path.of("src");
|
||||||
|
static final Path CLASSES = Path.of("classes");
|
||||||
|
|
||||||
static final File TestFile = new File("A.java");
|
static void init() throws Exception {
|
||||||
|
|
||||||
static void init() {
|
|
||||||
emitCode();
|
emitCode();
|
||||||
LUtils.compile(TestFile.getName());
|
CompilerUtils.compile(SRC, CLASSES);
|
||||||
LUtils.TestResult tr = LUtils.doExec(LUtils.JAVA_CMD.getAbsolutePath(),
|
OutputAnalyzer outputAnalyzer = executeProcess(createTestJavaProcessBuilder(
|
||||||
"-Djdk.invoke.LambdaMetafactory.dumpProxyClassFiles=true",
|
"-Djdk.invoke.LambdaMetafactory.dumpProxyClassFiles=true",
|
||||||
"-cp", ".", "A");
|
"-cp", CLASSES.toString(), "A"));
|
||||||
if (tr.exitValue != 0) {
|
outputAnalyzer.shouldHaveExitValue(0);
|
||||||
System.out.println("Error: " + tr.toString());
|
|
||||||
throw new RuntimeException("could not create proxy classes");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void emitCode() {
|
static void emitCode() throws IOException {
|
||||||
ArrayList<String> scratch = new ArrayList<>();
|
ArrayList<String> scratch = new ArrayList<>();
|
||||||
scratch.add("import java.util.function.*;");
|
scratch.add("import java.util.function.*;");
|
||||||
scratch.add("class A {");
|
scratch.add("class A {");
|
||||||
@ -89,7 +92,10 @@ public class LambdaAsm {
|
|||||||
scratch.add(" I.d();");
|
scratch.add(" I.d();");
|
||||||
scratch.add(" }");
|
scratch.add(" }");
|
||||||
scratch.add("}");
|
scratch.add("}");
|
||||||
LUtils.createFile(TestFile, scratch);
|
|
||||||
|
Path testFile = SRC.resolve("A.java");
|
||||||
|
Files.createDirectories(SRC);
|
||||||
|
Files.write(testFile, scratch, Charset.defaultCharset());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void checkMethod(String cname, String mname, ConstantPool cp,
|
static void checkMethod(String cname, String mname, ConstantPool cp,
|
||||||
|
@ -24,20 +24,23 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8025636
|
* @bug 8025636
|
||||||
* @summary Synthetic frames should be hidden in exceptions
|
* @library /test/lib/
|
||||||
* @modules java.base/jdk.internal.org.objectweb.asm
|
* @modules java.base/jdk.internal.org.objectweb.asm
|
||||||
* jdk.compiler
|
* jdk.compiler
|
||||||
* @compile -XDignore.symbol.file LUtils.java LambdaStackTrace.java
|
* @compile LambdaStackTrace.java
|
||||||
* @run main LambdaStackTrace
|
* @run main LambdaStackTrace
|
||||||
|
* @summary Synthetic frames should be hidden in exceptions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import jdk.internal.org.objectweb.asm.ClassWriter;
|
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||||
|
import jdk.test.lib.compiler.CompilerUtils;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_ABSTRACT;
|
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_ABSTRACT;
|
||||||
@ -47,7 +50,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.V1_7;
|
|||||||
|
|
||||||
public class LambdaStackTrace {
|
public class LambdaStackTrace {
|
||||||
|
|
||||||
static File classes = new File(System.getProperty("test.classes"));
|
static Path CLASSES = Path.of(System.getProperty("test.classes", "."));
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
testBasic();
|
testBasic();
|
||||||
@ -121,12 +124,8 @@ public class LambdaStackTrace {
|
|||||||
// We can't let javac compile these interfaces because in > 1.8 it will insert
|
// We can't let javac compile these interfaces because in > 1.8 it will insert
|
||||||
// bridge methods into the interfaces - we want code that looks like <= 1.7,
|
// bridge methods into the interfaces - we want code that looks like <= 1.7,
|
||||||
// so we generate it.
|
// so we generate it.
|
||||||
try (FileOutputStream fw = new FileOutputStream(new File(classes, "Maker.class"))) {
|
Files.write(CLASSES.resolve("Maker.class"), generateMaker());
|
||||||
fw.write(generateMaker());
|
Files.write(CLASSES.resolve("StringMaker.class"), generateStringMaker());
|
||||||
}
|
|
||||||
try (FileOutputStream fw = new FileOutputStream(new File(classes, "StringMaker.class"))) {
|
|
||||||
fw.write(generateStringMaker());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] generateMaker() {
|
private static byte[] generateMaker() {
|
||||||
@ -154,7 +153,7 @@ public class LambdaStackTrace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void emitCode(File f) {
|
static void emitCode(Path file) throws IOException {
|
||||||
ArrayList<String> scratch = new ArrayList<>();
|
ArrayList<String> scratch = new ArrayList<>();
|
||||||
scratch.add("public class Caller {");
|
scratch.add("public class Caller {");
|
||||||
scratch.add(" public static void callStringMaker() {");
|
scratch.add(" public static void callStringMaker() {");
|
||||||
@ -166,13 +165,17 @@ public class LambdaStackTrace {
|
|||||||
scratch.add(" ((Maker) sm).make();"); // <-- This will call the bridge method
|
scratch.add(" ((Maker) sm).make();"); // <-- This will call the bridge method
|
||||||
scratch.add(" }");
|
scratch.add(" }");
|
||||||
scratch.add("}");
|
scratch.add("}");
|
||||||
LUtils.createFile(f, scratch);
|
|
||||||
|
Files.write(file, scratch, Charset.defaultCharset());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void compileCaller() {
|
static void compileCaller() throws IOException {
|
||||||
File caller = new File(classes, "Caller.java");
|
Path src = Path.of("src");
|
||||||
|
Files.createDirectories(src);
|
||||||
|
|
||||||
|
Path caller = src.resolve("Caller.java");
|
||||||
emitCode(caller);
|
emitCode(caller);
|
||||||
LUtils.compile("-cp", classes.getAbsolutePath(), "-d", classes.getAbsolutePath(), caller.getAbsolutePath());
|
CompilerUtils.compile(src, CLASSES, "-cp", CLASSES.toAbsolutePath().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void verifyFrames(StackTraceElement[] stack, String... patterns) throws Exception {
|
private static void verifyFrames(StackTraceElement[] stack, String... patterns) throws Exception {
|
||||||
|
@ -24,14 +24,16 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8023524 8304846
|
* @bug 8023524 8304846
|
||||||
* @summary tests logging generated classes for lambda
|
* @requires vm.flagless
|
||||||
|
* @library /test/lib/
|
||||||
* @library /java/nio/file
|
* @library /java/nio/file
|
||||||
* @modules jdk.compiler
|
* @modules jdk.compiler
|
||||||
* jdk.zipfs
|
* jdk.zipfs
|
||||||
* @run testng LogGeneratedClassesTest
|
* @run testng LogGeneratedClassesTest
|
||||||
|
* @summary tests logging generated classes for lambda
|
||||||
*/
|
*/
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
@ -40,18 +42,21 @@ import java.nio.file.Path;
|
|||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.attribute.PosixFileAttributeView;
|
import java.nio.file.attribute.PosixFileAttributeView;
|
||||||
|
|
||||||
|
import jdk.test.lib.compiler.CompilerUtils;
|
||||||
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import org.testng.SkipException;
|
|
||||||
|
|
||||||
import static java.nio.file.attribute.PosixFilePermissions.*;
|
import static java.nio.file.attribute.PosixFilePermissions.*;
|
||||||
|
import static jdk.test.lib.process.ProcessTools.*;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertFalse;
|
import static org.testng.Assert.assertFalse;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
public class LogGeneratedClassesTest extends LUtils {
|
public class LogGeneratedClassesTest {
|
||||||
static final Path DUMP_LAMBDA_PROXY_CLASS_FILES = Path.of("DUMP_LAMBDA_PROXY_CLASS_FILES");
|
static final Path DUMP_LAMBDA_PROXY_CLASS_FILES = Path.of("DUMP_LAMBDA_PROXY_CLASS_FILES");
|
||||||
|
static final Path CLASSES = Path.of("classes").toAbsolutePath();
|
||||||
String longFQCN;
|
String longFQCN;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
@ -74,9 +79,8 @@ public class LogGeneratedClassesTest extends LUtils {
|
|||||||
scratch.add(" }");
|
scratch.add(" }");
|
||||||
scratch.add("}");
|
scratch.add("}");
|
||||||
|
|
||||||
File test = new File("TestLambda.java");
|
Path testLambda = Path.of("TestLambda.java");
|
||||||
createFile(test, scratch);
|
Files.write(testLambda, scratch, Charset.defaultCharset());
|
||||||
compile("-d", ".", test.getName());
|
|
||||||
|
|
||||||
scratch.remove(0);
|
scratch.remove(0);
|
||||||
scratch.remove(0);
|
scratch.remove(0);
|
||||||
@ -91,9 +95,10 @@ public class LogGeneratedClassesTest extends LUtils {
|
|||||||
sb.append(";");
|
sb.append(";");
|
||||||
sb.insert(0, "package ");
|
sb.insert(0, "package ");
|
||||||
scratch.add(0, sb.toString());
|
scratch.add(0, sb.toString());
|
||||||
test = new File("LongPackageName.java");
|
Path lpnTest = Path.of("LongPackageName.java");
|
||||||
createFile(test, scratch);
|
Files.write(lpnTest, scratch, Charset.defaultCharset());
|
||||||
compile("-d", ".", test.getName());
|
|
||||||
|
CompilerUtils.compile(Path.of("."), CLASSES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
@ -107,25 +112,26 @@ public class LogGeneratedClassesTest extends LUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNotLogging() {
|
public void testNotLogging() throws Exception {
|
||||||
TestResult tr = doExec(JAVA_CMD.getAbsolutePath(),
|
ProcessBuilder pb = createLimitedTestJavaProcessBuilder(
|
||||||
"-cp", ".",
|
"-cp", CLASSES.toString(),
|
||||||
"-Djava.security.manager=allow",
|
"-Djava.security.manager=allow",
|
||||||
"com.example.TestLambda");
|
"com.example.TestLambda");
|
||||||
tr.assertZero("Should still return 0");
|
executeProcess(pb).shouldHaveExitValue(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLogging() throws IOException {
|
public void testLogging() throws Exception {
|
||||||
Path testDir = Path.of("dump");
|
Path testDir = Path.of("dump");
|
||||||
Path dumpDir = testDir.resolve(DUMP_LAMBDA_PROXY_CLASS_FILES);
|
Path dumpDir = testDir.resolve(DUMP_LAMBDA_PROXY_CLASS_FILES);
|
||||||
Files.createDirectory(testDir);
|
Files.createDirectory(testDir);
|
||||||
TestResult tr = doExec(JAVA_CMD.getAbsolutePath(),
|
ProcessBuilder pb = createLimitedTestJavaProcessBuilder(
|
||||||
"-cp", "..",
|
"-cp", CLASSES.toString(),
|
||||||
"-Duser.dir=" + testDir.toAbsolutePath(),
|
|
||||||
"-Djava.security.manager=allow",
|
"-Djava.security.manager=allow",
|
||||||
"-Djdk.invoke.LambdaMetafactory.dumpProxyClassFiles",
|
"-Djdk.invoke.LambdaMetafactory.dumpProxyClassFiles",
|
||||||
"com.example.TestLambda");
|
"com.example.TestLambda").directory(testDir.toFile());
|
||||||
|
executeProcess(pb).shouldHaveExitValue(0);
|
||||||
|
|
||||||
// 2 our own class files. We don't care about the others
|
// 2 our own class files. We don't care about the others
|
||||||
assertEquals(Files.find(
|
assertEquals(Files.find(
|
||||||
dumpDir,
|
dumpDir,
|
||||||
@ -133,23 +139,22 @@ public class LogGeneratedClassesTest extends LUtils {
|
|||||||
(p, a) -> p.startsWith(dumpDir.resolve("com/example"))
|
(p, a) -> p.startsWith(dumpDir.resolve("com/example"))
|
||||||
&& a.isRegularFile()).count(),
|
&& a.isRegularFile()).count(),
|
||||||
2, "Two lambda captured");
|
2, "Two lambda captured");
|
||||||
tr.assertZero("Should still return 0");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDumpDirNotExist() throws IOException {
|
public void testDumpDirNotExist() throws Exception {
|
||||||
Path testDir = Path.of("NotExist");
|
Path testDir = Path.of("NotExist");
|
||||||
Path dumpDir = testDir.resolve(DUMP_LAMBDA_PROXY_CLASS_FILES);
|
Path dumpDir = testDir.resolve(DUMP_LAMBDA_PROXY_CLASS_FILES);
|
||||||
Files.createDirectory(testDir);
|
Files.createDirectory(testDir);
|
||||||
TestUtil.removeAll(dumpDir);
|
TestUtil.removeAll(dumpDir);
|
||||||
|
|
||||||
assertFalse(Files.exists(dumpDir));
|
assertFalse(Files.exists(dumpDir));
|
||||||
TestResult tr = doExec(JAVA_CMD.getAbsolutePath(),
|
|
||||||
"-cp", "..",
|
ProcessBuilder pb = createLimitedTestJavaProcessBuilder(
|
||||||
"-Duser.dir=" + testDir.toAbsolutePath(),
|
"-cp", CLASSES.toString(),
|
||||||
"-Djava.security.manager=allow",
|
"-Djava.security.manager=allow",
|
||||||
"-Djdk.invoke.LambdaMetafactory.dumpProxyClassFiles",
|
"-Djdk.invoke.LambdaMetafactory.dumpProxyClassFiles",
|
||||||
"com.example.TestLambda");
|
"com.example.TestLambda").directory(testDir.toFile());
|
||||||
|
executeProcess(pb).shouldHaveExitValue(0);
|
||||||
|
|
||||||
// The dump directory will be created if not exist
|
// The dump directory will be created if not exist
|
||||||
assertEquals(Files.find(
|
assertEquals(Files.find(
|
||||||
@ -158,27 +163,23 @@ public class LogGeneratedClassesTest extends LUtils {
|
|||||||
(p, a) -> p.startsWith(dumpDir.resolve("com/example"))
|
(p, a) -> p.startsWith(dumpDir.resolve("com/example"))
|
||||||
&& a.isRegularFile()).count(),
|
&& a.isRegularFile()).count(),
|
||||||
2, "Two lambda captured");
|
2, "Two lambda captured");
|
||||||
tr.assertZero("Should still return 0");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDumpDirIsFile() throws IOException {
|
public void testDumpDirIsFile() throws Exception {
|
||||||
Path testDir = Path.of("notDir");
|
Path testDir = Path.of("notDir");
|
||||||
Path dumpFile = testDir.resolve(DUMP_LAMBDA_PROXY_CLASS_FILES);
|
Path dumpFile = testDir.resolve(DUMP_LAMBDA_PROXY_CLASS_FILES);
|
||||||
Files.createDirectory(testDir);
|
Files.createDirectory(testDir);
|
||||||
Files.createFile(dumpFile);
|
Files.createFile(dumpFile);
|
||||||
assertTrue(Files.isRegularFile(dumpFile));
|
assertTrue(Files.isRegularFile(dumpFile));
|
||||||
TestResult tr = doExec(JAVA_CMD.getAbsolutePath(),
|
ProcessBuilder pb = createLimitedTestJavaProcessBuilder(
|
||||||
"-cp", "..",
|
"-cp", CLASSES.toString(),
|
||||||
"-Duser.dir=" + testDir.toAbsolutePath(),
|
|
||||||
"-Djava.security.manager=allow",
|
"-Djava.security.manager=allow",
|
||||||
"-Djdk.invoke.LambdaMetafactory.dumpProxyClassFiles",
|
"-Djdk.invoke.LambdaMetafactory.dumpProxyClassFiles",
|
||||||
"com.example.TestLambda");
|
"com.example.TestLambda").directory(testDir.toFile());
|
||||||
assertEquals(tr.testOutput.stream()
|
executeProcess(pb)
|
||||||
.filter(s -> s.contains("DUMP_LAMBDA_PROXY_CLASS_FILES is not a directory"))
|
.shouldContain("DUMP_LAMBDA_PROXY_CLASS_FILES is not a directory")
|
||||||
.count(),
|
.shouldNotHaveExitValue(0);
|
||||||
1, "only show error once");
|
|
||||||
assertTrue(tr.exitValue != 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isWriteableDirectory(Path p) {
|
private static boolean isWriteableDirectory(Path p) {
|
||||||
@ -205,7 +206,7 @@ public class LogGeneratedClassesTest extends LUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDumpDirNotWritable() throws IOException {
|
public void testDumpDirNotWritable() throws Exception {
|
||||||
if (!Files.getFileStore(Paths.get("."))
|
if (!Files.getFileStore(Paths.get("."))
|
||||||
.supportsFileAttributeView(PosixFileAttributeView.class)) {
|
.supportsFileAttributeView(PosixFileAttributeView.class)) {
|
||||||
// No easy way to setup readonly directory without POSIX
|
// No easy way to setup readonly directory without POSIX
|
||||||
@ -230,35 +231,33 @@ public class LogGeneratedClassesTest extends LUtils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TestResult tr = doExec(JAVA_CMD.getAbsolutePath(),
|
ProcessBuilder pb = createLimitedTestJavaProcessBuilder(
|
||||||
"-cp", "..",
|
"-cp", CLASSES.toString(),
|
||||||
"-Duser.dir=" + testDir.toAbsolutePath(),
|
|
||||||
"-Djava.security.manager=allow",
|
"-Djava.security.manager=allow",
|
||||||
"-Djdk.invoke.LambdaMetafactory.dumpProxyClassFiles",
|
"-Djdk.invoke.LambdaMetafactory.dumpProxyClassFiles",
|
||||||
"com.example.TestLambda");
|
"com.example.TestLambda").directory(testDir.toFile());
|
||||||
assertEquals(tr.testOutput.stream()
|
executeProcess(pb)
|
||||||
.filter(s -> s.contains("DUMP_LAMBDA_PROXY_CLASS_FILES is not writable"))
|
.shouldContain("DUMP_LAMBDA_PROXY_CLASS_FILES is not writable")
|
||||||
.count(),
|
.shouldNotHaveExitValue(0);
|
||||||
1, "only show error once");
|
|
||||||
assertTrue(tr.exitValue != 0);
|
|
||||||
} finally {
|
} finally {
|
||||||
TestUtil.removeAll(testDir);
|
TestUtil.removeAll(testDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLoggingException() throws IOException {
|
public void testLoggingException() throws Exception {
|
||||||
Path testDir = Path.of("dumpLong");
|
Path testDir = Path.of("dumpLong");
|
||||||
Path dumpDir = testDir.resolve(DUMP_LAMBDA_PROXY_CLASS_FILES);
|
Path dumpDir = testDir.resolve(DUMP_LAMBDA_PROXY_CLASS_FILES);
|
||||||
Files.createDirectories(dumpDir.resolve("com/example/nonsense"));
|
Files.createDirectories(dumpDir.resolve("com/example/nonsense"));
|
||||||
Files.createFile(dumpDir.resolve("com/example/nonsense/nonsense"));
|
Files.createFile(dumpDir.resolve("com/example/nonsense/nonsense"));
|
||||||
TestResult tr = doExec(JAVA_CMD.getAbsolutePath(),
|
ProcessBuilder pb = createLimitedTestJavaProcessBuilder(
|
||||||
"-cp", "..",
|
"-cp", CLASSES.toString(),
|
||||||
"-Duser.dir=" + testDir.toAbsolutePath(),
|
|
||||||
"-Djava.security.manager=allow",
|
"-Djava.security.manager=allow",
|
||||||
"-Djdk.invoke.LambdaMetafactory.dumpProxyClassFiles",
|
"-Djdk.invoke.LambdaMetafactory.dumpProxyClassFiles",
|
||||||
longFQCN);
|
longFQCN).directory(testDir.toFile());
|
||||||
assertEquals(tr.testOutput.stream()
|
OutputAnalyzer outputAnalyzer = executeProcess(pb);
|
||||||
|
outputAnalyzer.shouldHaveExitValue(0);
|
||||||
|
assertEquals(outputAnalyzer.asLines().stream()
|
||||||
.filter(s -> s.startsWith("WARNING: Exception"))
|
.filter(s -> s.startsWith("WARNING: Exception"))
|
||||||
.count(),
|
.count(),
|
||||||
2, "show error each capture");
|
2, "show error each capture");
|
||||||
@ -279,6 +278,5 @@ public class LogGeneratedClassesTest extends LUtils {
|
|||||||
assertEquals(Files.walk(dumpDir)
|
assertEquals(Files.walk(dumpDir)
|
||||||
.filter(filter)
|
.filter(filter)
|
||||||
.count(), 5, "Two lambda captured failed to log");
|
.count(), 5, "Two lambda captured failed to log");
|
||||||
tr.assertZero("Should still return 0");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -31,37 +31,15 @@
|
|||||||
|
|
||||||
// Test disabled on AIX since we cannot invoke the JVM on the primordial thread.
|
// Test disabled on AIX since we cannot invoke the JVM on the primordial thread.
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Map;
|
|
||||||
import jdk.test.lib.Platform;
|
import jdk.test.lib.Platform;
|
||||||
import jdk.test.lib.process.OutputAnalyzer;
|
import jdk.test.lib.process.ProcessTools;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
|
|
||||||
public class CallerAccessTest {
|
public class CallerAccessTest {
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws Exception {
|
||||||
Path launcher = Paths.get(System.getProperty("test.nativepath"), "CallerAccessTest");
|
ProcessBuilder pb = ProcessTools.createNativeTestProcessBuilder("CallerAccessTest");
|
||||||
ProcessBuilder pb = new ProcessBuilder(launcher.toString());
|
System.out.println("Launching: " + pb.command() + " shared library path: " +
|
||||||
Map<String, String> env = pb.environment();
|
pb.environment().get(Platform.sharedLibraryPathVariableName()));
|
||||||
|
ProcessTools.executeProcess(pb).shouldHaveExitValue(0);
|
||||||
String libDir = Platform.libDir().toString();
|
|
||||||
String vmDir = Platform.jvmLibDir().toString();
|
|
||||||
|
|
||||||
// set up shared library path
|
|
||||||
String sharedLibraryPathEnvName = Platform.sharedLibraryPathVariableName();
|
|
||||||
env.compute(sharedLibraryPathEnvName,
|
|
||||||
(k, v) -> (v == null) ? libDir : v + File.pathSeparator + libDir);
|
|
||||||
env.compute(sharedLibraryPathEnvName,
|
|
||||||
(k, v) -> (v == null) ? vmDir : v + File.pathSeparator + vmDir);
|
|
||||||
|
|
||||||
System.out.println("Launching: " + launcher + " shared library path: " +
|
|
||||||
env.get(sharedLibraryPathEnvName));
|
|
||||||
new OutputAnalyzer(pb.start())
|
|
||||||
.outputTo(System.out)
|
|
||||||
.errorTo(System.err)
|
|
||||||
.shouldHaveExitValue(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ import java.io.File;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
import jdk.test.lib.JDKToolFinder;
|
|
||||||
import jdk.test.lib.compiler.CompilerUtils;
|
import jdk.test.lib.compiler.CompilerUtils;
|
||||||
import jdk.test.lib.process.OutputAnalyzer;
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
import jdk.test.lib.process.ProcessTools;
|
import jdk.test.lib.process.ProcessTools;
|
||||||
@ -34,12 +33,12 @@ import jdk.test.lib.util.JarBuilder;
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8308184
|
* @bug 8308184
|
||||||
* @summary Verify that an application can be launched when the classpath contains large number of
|
|
||||||
* jars and the java.protocol.handler.pkgs system property is set
|
|
||||||
* @library /test/lib/
|
* @library /test/lib/
|
||||||
* @build jdk.test.lib.util.JarBuilder jdk.test.lib.compiler.CompilerUtils
|
* @build jdk.test.lib.util.JarBuilder jdk.test.lib.compiler.CompilerUtils
|
||||||
* jdk.test.lib.process.ProcessTools
|
* jdk.test.lib.process.ProcessTools
|
||||||
* @run driver LargeClasspathWithPkgPrefix
|
* @run driver LargeClasspathWithPkgPrefix
|
||||||
|
* @summary Verify that an application can be launched when the classpath contains large number of
|
||||||
|
* jars and the java.protocol.handler.pkgs system property is set
|
||||||
*/
|
*/
|
||||||
public class LargeClasspathWithPkgPrefix {
|
public class LargeClasspathWithPkgPrefix {
|
||||||
|
|
||||||
@ -126,8 +125,7 @@ public class LargeClasspathWithPkgPrefix {
|
|||||||
|
|
||||||
// java -Djava.protocol.handler.pkgs=foo.bar.some.nonexistent.pkg -cp <classpath> Foo
|
// java -Djava.protocol.handler.pkgs=foo.bar.some.nonexistent.pkg -cp <classpath> Foo
|
||||||
private static void launchApplication(String classPath) throws Exception {
|
private static void launchApplication(String classPath) throws Exception {
|
||||||
String java = JDKToolFinder.getJDKTool("java");
|
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
|
||||||
ProcessBuilder pb = new ProcessBuilder(java,
|
|
||||||
"-Djava.protocol.handler.pkgs=foo.bar.some.nonexistent.pkg",
|
"-Djava.protocol.handler.pkgs=foo.bar.some.nonexistent.pkg",
|
||||||
"-cp", classPath,
|
"-cp", classPath,
|
||||||
"Foo");
|
"Foo");
|
||||||
|
@ -23,11 +23,12 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @summary Basic test of VM::getRuntimeArguments
|
* @requires vm.flagless
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @modules java.base/jdk.internal.misc
|
* @modules java.base/jdk.internal.misc
|
||||||
* jdk.zipfs
|
* jdk.zipfs
|
||||||
* @run testng RuntimeArguments
|
* @run testng RuntimeArguments
|
||||||
|
* @summary Basic test of VM::getRuntimeArguments
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -46,7 +47,6 @@ import org.testng.annotations.Test;
|
|||||||
import static org.testng.Assert.*;
|
import static org.testng.Assert.*;
|
||||||
|
|
||||||
public class RuntimeArguments {
|
public class RuntimeArguments {
|
||||||
static final String TEST_CLASSES = System.getProperty("test.classes");
|
|
||||||
static final List<String> VM_OPTIONS = getInitialOptions();
|
static final List<String> VM_OPTIONS = getInitialOptions();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -112,11 +112,9 @@ public class RuntimeArguments {
|
|||||||
|
|
||||||
@Test(dataProvider = "options")
|
@Test(dataProvider = "options")
|
||||||
public void test(List<String> args, List<String> expected) throws Exception {
|
public void test(List<String> args, List<String> expected) throws Exception {
|
||||||
// launch a test program
|
// launch a test program with classpath set by ProcessTools::createLimitedTestJavaProcessBuilder
|
||||||
// $ java <args> -classpath <cpath> RuntimeArguments <vm_options> <expected>
|
// $ java <args> RuntimeArguments <vm_options> <expected>
|
||||||
Stream<String> options = Stream.concat(args.stream(),
|
Stream<String> options = Stream.concat(args.stream(), Stream.of("RuntimeArguments"));
|
||||||
Stream.of("-classpath", TEST_CLASSES, "RuntimeArguments"));
|
|
||||||
|
|
||||||
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
|
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
|
||||||
// The runtime image may be created with jlink --add-options
|
// The runtime image may be created with jlink --add-options
|
||||||
// The initial VM options will be included in the result
|
// The initial VM options will be included in the result
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,11 +24,12 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8170859
|
* @bug 8170859
|
||||||
* @summary Ensure no incubator modules are resolved by default in the image
|
* @requires vm.flagless
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @modules jdk.compiler
|
* @modules jdk.compiler
|
||||||
* @build jdk.test.lib.compiler.CompilerUtils
|
* @build jdk.test.lib.compiler.CompilerUtils
|
||||||
* @run testng DefaultImage
|
* @run testng DefaultImage
|
||||||
|
* @summary Ensure no incubator modules are resolved by default in the image
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -43,6 +44,7 @@ import java.util.function.Consumer;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import jdk.test.lib.compiler.CompilerUtils;
|
import jdk.test.lib.compiler.CompilerUtils;
|
||||||
|
|
||||||
|
import jdk.test.lib.process.ProcessTools;
|
||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
@ -108,10 +110,8 @@ public class DefaultImage {
|
|||||||
static ToolResult java(String... opts) throws Throwable {
|
static ToolResult java(String... opts) throws Throwable {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
PrintStream ps = new PrintStream(baos);
|
PrintStream ps = new PrintStream(baos);
|
||||||
String[] options = Stream.concat(Stream.of(getJava()), Stream.of(opts))
|
|
||||||
.toArray(String[]::new);
|
|
||||||
|
|
||||||
ProcessBuilder pb = new ProcessBuilder(options);
|
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(opts);
|
||||||
int exitValue = executeCommand(pb).outputTo(ps)
|
int exitValue = executeCommand(pb).outputTo(ps)
|
||||||
.errorTo(ps)
|
.errorTo(ps)
|
||||||
.getExitValue();
|
.getExitValue();
|
||||||
@ -155,15 +155,6 @@ public class DefaultImage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getJava() {
|
|
||||||
Path image = Paths.get(JAVA_HOME);
|
|
||||||
boolean isWindows = System.getProperty("os.name").startsWith("Windows");
|
|
||||||
Path java = image.resolve("bin").resolve(isWindows ? "java.exe" : "java");
|
|
||||||
if (Files.notExists(java))
|
|
||||||
throw new RuntimeException(java + " not found");
|
|
||||||
return java.toAbsolutePath().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean isExplodedBuild() {
|
static boolean isExplodedBuild() {
|
||||||
Path modulesPath = Paths.get(JAVA_HOME).resolve("lib").resolve("modules");
|
Path modulesPath = Paths.get(JAVA_HOME).resolve("lib").resolve("modules");
|
||||||
return Files.notExists(modulesPath);
|
return Files.notExists(modulesPath);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,7 +24,7 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8170859
|
* @bug 8170859
|
||||||
* @summary Basic test for incubator modules in jmods and images
|
* @requires vm.flagless
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @key intermittent
|
* @key intermittent
|
||||||
* @modules jdk.compiler jdk.jartool jdk.jlink
|
* @modules jdk.compiler jdk.jartool jdk.jlink
|
||||||
@ -32,6 +32,7 @@
|
|||||||
* jdk.test.lib.util.FileUtils
|
* jdk.test.lib.util.FileUtils
|
||||||
* jdk.test.lib.compiler.CompilerUtils
|
* jdk.test.lib.compiler.CompilerUtils
|
||||||
* @run testng/othervm ImageModules
|
* @run testng/othervm ImageModules
|
||||||
|
* @summary Basic test for incubator modules in jmods and images
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user