Skip to content

Commit

Permalink
Merge master jdk-17.0.13+5 into openj9-staging
Browse files Browse the repository at this point in the history
Signed-off-by: J9 Build <j9build@ca.ibm.com>
  • Loading branch information
j9build committed Aug 29, 2024
2 parents d440eb1 + 5fef984 commit f4354fa
Show file tree
Hide file tree
Showing 36 changed files with 1,585 additions and 624 deletions.
18 changes: 13 additions & 5 deletions test/hotspot/jtreg/compiler/codecache/CodeCacheFullCountTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,20 @@ public static void main(String args[]) throws Throwable {
}
}

public static void wasteCodeCache() throws Exception {
public static void wasteCodeCache() throws Throwable {
URL url = CodeCacheFullCountTest.class.getProtectionDomain().getCodeSource().getLocation();

for (int i = 0; i < 500; i++) {
ClassLoader cl = new MyClassLoader(url);
refClass(cl.loadClass("SomeClass"));
try {
for (int i = 0; i < 500; i++) {
ClassLoader cl = new MyClassLoader(url);
refClass(cl.loadClass("SomeClass"));
}
} catch (Throwable t) {
// Expose the root cause of the Throwable instance.
while (t.getCause() != null) {
t = t.getCause();
}
throw t;
}
}

Expand All @@ -59,7 +67,7 @@ public static void runTest() throws Throwable {
"-XX:ReservedCodeCacheSize=2496k", "-XX:-UseCodeCacheFlushing", "CodeCacheFullCountTest", "WasteCodeCache");
OutputAnalyzer oa = ProcessTools.executeProcess(pb);
// Ignore adapter creation failures
if (oa.getExitValue() != 0 && !oa.getStderr().contains("Out of space in CodeCache for adapters")) {
if (oa.getExitValue() != 0 && !oa.getOutput().contains("Out of space in CodeCache for adapters")) {
oa.reportDiagnosticSummary();
throw new RuntimeException("VM finished with exit code " + oa.getExitValue());
}
Expand Down
115 changes: 101 additions & 14 deletions test/hotspot/jtreg/containers/docker/TestJcmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,22 @@ public class TestJcmd {
private static final String IMAGE_NAME = Common.imageName("jcmd");
private static final int TIME_TO_RUN_CONTAINER_PROCESS = (int) (10 * Utils.TIMEOUT_FACTOR); // seconds
private static final String CONTAINER_NAME = "test-container";
private static final boolean IS_PODMAN = Container.ENGINE_COMMAND.contains("podman");
private static final String ROOT_UID = "0";


public static void main(String[] args) throws Exception {
DockerTestUtils.canTestDocker();

// See JDK-8273216 for details
if (Container.ENGINE_COMMAND.equals("podman")) {
throw new SkippedException("JCMD does not work across container boundaries when using Podman");
// podman versions below 3.3.1 hava a bug where cross-container testing with correct
// permissions fails. See JDK-8273216
if (IS_PODMAN && PodmanVersion.VERSION_3_3_1.compareTo(getPodmanVersion()) > 0) {
throw new SkippedException("Podman version too old for this test. Expected >= 3.3.1");
}

// Need to create a custom dockerfile where user name and id, as well as group name and id
// of the JVM running in container must match the ones from the inspecting JCMD process.
String uid = getId("-u");
String gid = getId("-g");
String userName = getId("-un");
String groupName = getId("-gn");
String content = generateCustomDockerfile(uid, gid, userName, groupName);
String content = generateCustomDockerfile();
DockerTestUtils.buildJdkContainerImage(IMAGE_NAME, content);

try {
Expand Down Expand Up @@ -135,17 +134,26 @@ private static void testVmInfo(long pid) throws Exception {

// Need to make sure that user name+id and group name+id are created for the image, and
// match the host system. This is necessary to allow proper permission/access for JCMD.
private static String generateCustomDockerfile(String uid, String gid,
String userName, String groupName) throws Exception {
// For podman --userns=keep-id is sufficient.
private static String generateCustomDockerfile() throws Exception {
StringBuilder sb = new StringBuilder();
sb.append(String.format("FROM %s:%s\n", DockerfileConfig.getBaseImageName(),
DockerfileConfig.getBaseImageVersion()));
sb.append("COPY /jdk /jdk\n");
sb.append("ENV JAVA_HOME=/jdk\n");

sb.append(String.format("RUN groupadd --gid %s %s \n", gid, groupName));
sb.append(String.format("RUN useradd --uid %s --gid %s %s \n", uid, gid, userName));
sb.append(String.format("USER %s \n", userName));
if (!IS_PODMAN) { // only needed for docker
String uid = getId("-u");
String gid = getId("-g");
String userName = getId("-un");
String groupName = getId("-gn");
// Only needed when run as regular user. UID == 0 should already exist
if (!ROOT_UID.equals(uid)) {
sb.append(String.format("RUN groupadd --gid %s %s \n", gid, groupName));
sb.append(String.format("RUN useradd --uid %s --gid %s %s \n", uid, gid, userName));
sb.append(String.format("USER %s \n", userName));
}
}

sb.append("CMD [\"/bin/bash\"]\n");

Expand All @@ -155,12 +163,17 @@ private static String generateCustomDockerfile(String uid, String gid,

private static Process startObservedContainer() throws Exception {
DockerRunOptions opts = new DockerRunOptions(IMAGE_NAME, "/jdk/bin/java", "EventGeneratorLoop");
opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/")
opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/:z")
.addJavaOpts("-cp", "/test-classes/")
.addDockerOpts("--cap-add=SYS_PTRACE")
.addDockerOpts("--name", CONTAINER_NAME)
.addClassOptions("" + TIME_TO_RUN_CONTAINER_PROCESS);

if (IS_PODMAN) {
// map the current userid to the one in the target namespace
opts.addDockerOpts("--userns=keep-id");
}

// avoid large Xmx
opts.appendTestJavaOptions = false;

Expand Down Expand Up @@ -190,4 +203,78 @@ private static String getId(String param) throws Exception {
System.out.println("getId() " + param + " returning: " + result);
return result;
}

// pre: IS_PODMAN == true
private static String getPodmanVersionStr() {
if (!IS_PODMAN) {
return null;
}
try {
ProcessBuilder pb = new ProcessBuilder(Container.ENGINE_COMMAND, "--version");
OutputAnalyzer out = new OutputAnalyzer(pb.start())
.shouldHaveExitValue(0);
String result = out.asLines().get(0);
System.out.println(Container.ENGINE_COMMAND + " --version returning: " + result);
return result;
} catch (Exception e) {
System.out.println(Container.ENGINE_COMMAND + " --version command failed. Returning null");
return null;
}
}

private static PodmanVersion getPodmanVersion() {
return PodmanVersion.fromVersionString(getPodmanVersionStr());
}

private static class PodmanVersion implements Comparable<PodmanVersion> {
private static final PodmanVersion DEFAULT = new PodmanVersion(0, 0, 0);
private static final PodmanVersion VERSION_3_3_1 = new PodmanVersion(3, 3, 1);
private final int major;
private final int minor;
private final int micro;

private PodmanVersion(int major, int minor, int micro) {
this.major = major;
this.minor = minor;
this.micro = micro;
}

@Override
public int compareTo(PodmanVersion other) {
if (this.major > other.major) {
return 1;
} else if (this.major < other.major) {
return -1;
} else { // equal major
if (this.minor > other.minor) {
return 1;
} else if (this.minor < other.minor) {
return -1;
} else { // equal majors and minors
if (this.micro > other.micro) {
return 1;
} else if (this.micro < other.micro) {
return -1;
} else {
// equal majors, minors, micro
return 0;
}
}
}
}

private static PodmanVersion fromVersionString(String version) {
try {
// Example 'podman version 3.2.1'
String versNums = version.split("\\s+", 3)[2];
String[] numbers = versNums.split("\\.", 3);
return new PodmanVersion(Integer.parseInt(numbers[0]),
Integer.parseInt(numbers[1]),
Integer.parseInt(numbers[2]));
} catch (Exception e) {
System.out.println("Failed to parse podman version: " + version);
return DEFAULT;
}
}
}
}
49 changes: 39 additions & 10 deletions test/hotspot/jtreg/gc/stress/TestStressG1Humongous.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,41 @@
package gc.stress;

/*
* @test TestStressG1Humongous
* @test
* @key stress
* @summary Stress G1 by humongous allocations in situation near OOM
* @requires vm.gc.G1
* @requires !vm.flightRecorder
* @library /test/lib
* @modules java.base/jdk.internal.misc
* @run driver/timeout=1300 gc.stress.TestStressG1Humongous
* @run driver/timeout=180 gc.stress.TestStressG1Humongous 4 3 1.1 120
*/

/*
* @test
* @requires vm.gc.G1
* @requires !vm.flightRecorder
* @library /test/lib
* @modules java.base/jdk.internal.misc
* @run driver/timeout=180 gc.stress.TestStressG1Humongous 16 5 2.1 120
*/

/*
* @test
* @requires vm.gc.G1
* @requires !vm.flightRecorder
* @library /test/lib
* @modules java.base/jdk.internal.misc
* @run driver/timeout=180 gc.stress.TestStressG1Humongous 32 4 0.6 120
*/

/*
* @test
* @requires vm.gc.G1
* @requires !vm.flightRecorder
* @library /test/lib
* @modules java.base/jdk.internal.misc
* @run driver/timeout=900 gc.stress.TestStressG1Humongous 1 7 0.6 600
*/

import java.util.ArrayList;
Expand All @@ -48,17 +75,19 @@
public class TestStressG1Humongous{

public static void main(String[] args) throws Exception {
if (args.length != 4) {
throw new IllegalArgumentException("Test expects 4 arguments");
}

// Limit heap size on 32-bit platforms
int heapSize = Platform.is32bit() ? 512 : 1024;
// Heap size, region size, threads, humongous size, timeout
run(heapSize, 4, 3, 1.1, 120);
run(heapSize, 16, 5, 2.1, 120);
run(heapSize, 32, 4, 0.6, 120);
run(heapSize, 1, 7, 0.6, 600);
}

private static void run(int heapSize, int regionSize, int threads, double humongousSize, int timeout)
throws Exception {
// Region size, threads, humongous size, and timeout passed as @run arguments
int regionSize = Integer.parseInt(args[0]);
int threads = Integer.parseInt(args[1]);
double humongousSize = Double.parseDouble(args[2]);
int timeout = Integer.parseInt(args[3]);

ArrayList<String> options = new ArrayList<>();
Collections.addAll(options, Utils.getTestJavaOpts());
Collections.addAll(options,
Expand Down
1 change: 1 addition & 0 deletions test/hotspot/jtreg/runtime/cds/TestCDSVMCrash.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
/*
* @test TestCDSVMCrash
* @summary Verify that an exception is thrown when the VM crashes during executeAndLog
* @requires vm.cds
* @modules java.base/jdk.internal.misc
* @library /test/lib
* @run driver TestCDSVMCrash
Expand Down
59 changes: 28 additions & 31 deletions test/hotspot/jtreg/runtime/logging/ClassLoadUnloadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
import jdk.test.lib.classloader.ClassUnloadCommon;

public class ClassLoadUnloadTest {
private static OutputAnalyzer out;
private static ProcessBuilder pb;
private static class ClassUnloadTestMain {
public static void main(String... args) throws Exception {
String className = "test.Empty";
Expand All @@ -56,63 +54,62 @@ public static void main(String... args) throws Exception {
}
}

static void checkFor(String... outputStrings) throws Exception {
out = new OutputAnalyzer(pb.start());
static void checkFor(OutputAnalyzer output, String... outputStrings) throws Exception {
for (String s: outputStrings) {
out.shouldContain(s);
output.shouldContain(s);
}
out.shouldHaveExitValue(0);
}

static void checkAbsent(String... outputStrings) throws Exception {
out = new OutputAnalyzer(pb.start());
static void checkAbsent(OutputAnalyzer output, String... outputStrings) throws Exception {
for (String s: outputStrings) {
out.shouldNotContain(s);
output.shouldNotContain(s);
}
out.shouldHaveExitValue(0);
}

// Use the same command-line heap size setting as ../ClassUnload/UnloadTest.java
static ProcessBuilder exec(String... args) throws Exception {
static OutputAnalyzer exec(String... args) throws Exception {
List<String> argsList = new ArrayList<>();
Collections.addAll(argsList, args);
Collections.addAll(argsList, "-Xmn8m");
Collections.addAll(argsList, "-Dtest.class.path=" + System.getProperty("test.class.path", "."));
Collections.addAll(argsList, "-XX:+ClassUnloading");
Collections.addAll(argsList, ClassUnloadTestMain.class.getName());
return ProcessTools.createJavaProcessBuilder(argsList);
Collections.addAll(argsList, "-Xmn8m", "-Dtest.class.path=" + System.getProperty("test.class.path", "."),
"-XX:+ClassUnloading", ClassUnloadTestMain.class.getName());
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(argsList);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
return output;
}

public static void main(String... args) throws Exception {

OutputAnalyzer output;

// -Xlog:class+unload=info
pb = exec("-Xlog:class+unload=info");
checkFor("[class,unload]", "unloading class");
output = exec("-Xlog:class+unload=info");
checkFor(output, "[class,unload]", "unloading class");

// -Xlog:class+unload=off
pb = exec("-Xlog:class+unload=off");
checkAbsent("[class,unload]");
output = exec("-Xlog:class+unload=off");
checkAbsent(output,"[class,unload]");

// -Xlog:class+load=info
pb = exec("-Xlog:class+load=info");
checkFor("[class,load]", "java.lang.Object", "source:");
output = exec("-Xlog:class+load=info");
checkFor(output,"[class,load]", "java.lang.Object", "source:");

// -Xlog:class+load=debug
pb = exec("-Xlog:class+load=debug");
checkFor("[class,load]", "java.lang.Object", "source:", "klass:", "super:", "loader:", "bytes:");
output = exec("-Xlog:class+load=debug");
checkFor(output,"[class,load]", "java.lang.Object", "source:", "klass:", "super:", "loader:", "bytes:");

// -Xlog:class+load=off
pb = exec("-Xlog:class+load=off");
checkAbsent("[class,load]");
output = exec("-Xlog:class+load=off");
checkAbsent(output,"[class,load]");

// -verbose:class
pb = exec("-verbose:class");
checkFor("[class,load]", "java.lang.Object", "source:");
checkFor("[class,unload]", "unloading class");
output = exec("-verbose:class");
checkFor(output,"[class,load]", "java.lang.Object", "source:");
checkFor(output,"[class,unload]", "unloading class");

// -Xlog:class+loader+data=trace
pb = exec("-Xlog:class+loader+data=trace");
checkFor("[class,loader,data]", "create loader data");
output = exec("-Xlog:class+loader+data=trace");
checkFor(output, "[class,loader,data]", "create loader data");

}
}
Loading

0 comments on commit f4354fa

Please sign in to comment.