Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, 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
Expand All @@ -24,11 +24,13 @@
/**
* @test
* @requires vm.cds
* @requires vm.flagless
* @bug 8067187 8200078
* @summary Testing CDS dumping with the -XX:MaxMetaspaceSize=<size> option
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @run driver MaxMetaspaceSize
*/
Copy link
Contributor Author

@amosshi amosshi Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes the changes from JDK-8243945 ( commit 46fe7e3 ) on this file


import java.util.ArrayList;
Expand All @@ -45,12 +47,11 @@ public static void main(String[] args) throws Exception {
if (Platform.is64bit()) {
processArgs.add("-XX:MaxMetaspaceSize=3m");
processArgs.add("-XX:CompressedClassSpaceSize=1m");
processArgs.add("-XX:InitialBootClassLoaderMetaspaceSize=1m");
} else {
Copy link
Contributor Author

@amosshi amosshi Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes the changes from JDK-8251158 (commit 7ba6a6b ) on this file

processArgs.add("-XX:MaxMetaspaceSize=1m");
}

String msg = "Failed allocating metaspace object";
String msg = "OutOfMemoryError: Metaspace";
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(processArgs);
Copy link
Contributor Author

@amosshi amosshi Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes the changes from JDK-8261551 (commit 41657b1 ) on this file

CDSTestUtils.executeAndLog(pb, "dump").shouldContain(msg).shouldHaveExitValue(1);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, 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
Expand All @@ -26,17 +26,17 @@
* @summary Check to make sure that shared strings in the bootstrap CDS archive
* are actually shared
* @requires vm.cds.archived.java.heap
* @requires vm.flagless
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @build SharedStringsWb sun.hotspot.WhiteBox
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes the changes from JDK-8229267 ( commit e9b271d ) on this file

* @run driver ClassFileInstaller -jar whitebox.jar sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller -jar whitebox.jar sun.hotspot.WhiteBox
* @run driver SharedStrings
Copy link
Contributor Author

@amosshi amosshi Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes the changes from JDK-8263549 ( commit a7aba2b ) on this file

*/

import jdk.test.lib.cds.CDSTestUtils;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.helpers.ClassFileInstaller;

Copy link
Contributor Author

@amosshi amosshi Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes the changes from JDK-8263412 ( commit e834f99 ) on this file

public class SharedStrings {
public static void main(String[] args) throws Exception {
Expand Down
54 changes: 43 additions & 11 deletions test/hotspot/jtreg/runtime/appcds/MoveJDKTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021, 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
Expand Down Expand Up @@ -27,12 +27,10 @@
* @summary Test that CDS still works when the JDK is moved to a new directory
* @bug 8272345
* @requires vm.cds
* @requires vm.flagless
* @comment This test doesn't work on Windows because it depends on symlinks
* @requires os.family != "windows"
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* jdk.jartool/sun.tools.jar
* @compile test-classes/Hello.java
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes the changes from JDK-8229267 ( commit e9b271d ) on this file

* @run driver MoveJDKTest
*/
Expand All @@ -42,19 +40,21 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import jdk.test.lib.cds.CDSTestUtils;
import jdk.test.lib.process.OutputAnalyzer;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes the changes from JDK-8251213 ( commit c1093dc ) on this file


public class MoveJDKTest {
public static void main(String[] args) throws Exception {
String java_home_src = System.getProperty("java.home");
String java_home_dst = System.getProperty("user.dir") + File.separator + "moved_jdk";
String java_home_dst = CDSTestUtils.getOutputDir() + File.separator + "moved_jdk";

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes the changes from JDK-8251267 ( commit 291ba97 ) on this file

TestCommon.startNewArchiveName();
String jsaFile = TestCommon.getCurrentArchiveName();
String jsaOpt = "-XX:SharedArchiveFile=" + jsaFile;
{
ProcessBuilder pb = makeBuilder(java_home_src + "/bin/java", "-Xshare:dump", jsaOpt);
TestCommon.executeAndLog(pb, "dump");
TestCommon.executeAndLog(pb, "dump")
.shouldHaveExitValue(0);
}
{
ProcessBuilder pb = makeBuilder(java_home_src + "/bin/java",
Expand All @@ -63,6 +63,7 @@ public static void main(String[] args) throws Exception {
"-Xlog:class+path=info",
"-version");
OutputAnalyzer out = TestCommon.executeAndLog(pb, "exec-src");
out.shouldHaveExitValue(0);
out.shouldNotContain("shared class paths mismatch");
out.shouldNotContain("BOOT classpath mismatch");
}
Expand All @@ -78,6 +79,7 @@ public static void main(String[] args) throws Exception {
"-Xlog:class+path=info",
"-version");
OutputAnalyzer out = TestCommon.executeAndLog(pb, "exec-dst");
out.shouldHaveExitValue(0);
out.shouldNotContain("shared class paths mismatch");
out.shouldNotContain("BOOT classpath mismatch");
}
Expand All @@ -91,7 +93,8 @@ public static void main(String[] args) throws Exception {
"-Xshare:dump",
dumptimeBootAppendOpt,
jsaOpt);
TestCommon.executeAndLog(pb, "dump");
TestCommon.executeAndLog(pb, "dump")
.shouldHaveExitValue(0);
}
{
String runtimeBootAppendOpt = dumptimeBootAppendOpt + System.getProperty("path.separator") + helloJar;
Expand All @@ -102,9 +105,20 @@ public static void main(String[] args) throws Exception {
"-Xlog:class+path=info",
"-version");
OutputAnalyzer out = TestCommon.executeAndLog(pb, "exec-dst");
out.shouldHaveExitValue(0);
out.shouldNotContain("shared class paths mismatch");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes the changes from JDK-8272335 ( commit 75a0642 ) on this file

out.shouldNotContain("BOOT classpath mismatch");
}

// Test with no modules image in the <java home>/lib directory
renameModulesFile(java_home_dst);
{
ProcessBuilder pb = makeBuilder(java_home_dst + "/bin/java",
"-version");
OutputAnalyzer out = TestCommon.executeAndLog(pb, "exec-missing-modules");
out.shouldHaveExitValue(1);
out.shouldContain("Failed setting boot class path.");
}
}

// Do a cheap clone of the JDK. Most files can be sym-linked. However, $JAVA_HOME/bin/java and $JAVA_HOME/lib/.../libjvm.so"
Expand Down Expand Up @@ -142,6 +156,24 @@ static void clone(File src, File dst) throws Exception {
}
}

static void renameModulesFile(String javaHome) throws Exception {
String modulesDir = javaHome + File.separator + "lib";
File origModules = new File(modulesDir, "modules");
if (!origModules.exists()) {
throw new RuntimeException("modules file not found");
}

File renamedModules = new File(modulesDir, "orig_modules");
if (renamedModules.exists()) {
throw new RuntimeException("found orig_modules unexpectedly");
}

boolean success = origModules.renameTo(renamedModules);
if (!success) {
throw new RuntimeException("rename modules file failed");
}
}

static ProcessBuilder makeBuilder(String... args) throws Exception {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes the changes from JDK-8205946 ( commit a10d6e7 ) on this file

System.out.print("[");
for (String s : args) {
Expand All @@ -152,12 +184,12 @@ static ProcessBuilder makeBuilder(String... args) throws Exception {
}

private static String copyFakeModulesFromHelloJar() throws Exception {
String classDir = System.getProperty("test.classes");
String outDir = CDSTestUtils.getOutputDir();
String newFile = "hello.modules";
String path = classDir + File.separator + newFile;
String path = outDir + File.separator + newFile;

Files.copy(Paths.get(classDir, "hello.jar"),
Paths.get(classDir, newFile),
Files.copy(Paths.get(outDir, "hello.jar"),
Paths.get(outDir, newFile),
StandardCopyOption.REPLACE_EXISTING);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes the changes from JDK-8251213 ( commit c1093dc ) on this file

return path;
}
Expand Down
45 changes: 45 additions & 0 deletions test/hotspot/jtreg/runtime/appcds/VerifyWithDefaultArchive.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2021, Alibaba Group Holding Limited. 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.
*
*/

/*
* @test
* @bug 8264337
* @summary test default cds archive when turning on VerifySharedSpaces
* @requires vm.flagless
* @requires vm.cds
* @library /test/lib
* @run driver VerifyWithDefaultArchive
*/

import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;

public class VerifyWithDefaultArchive {
public static void main(String... args) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:cds", "-XX:+VerifySharedSpaces", "-version");
OutputAnalyzer out = new OutputAnalyzer(pb.start());
out.shouldNotContain("relocation bitmap CRC error");
out.shouldHaveExitValue(0);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
/*
* Copyright (c) 2018, 2021, 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
Expand All @@ -25,15 +25,12 @@
* @test
* @summary Test archived module graph with custom runtime image
* @requires vm.cds.archived.java.heap
* @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/appcds
* @modules java.base/jdk.internal.module
* java.management
* jdk.jlink
* jdk.compiler
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes the changes from JDK-8229267 ( commit e9b271d ) on this file

* @requires vm.flagless
* @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/cds/appcds
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes the changes from JDK-8202339 ( commit 1ed3649 ) on this file

* @build sun.hotspot.WhiteBox
* @compile CheckArchivedModuleApp.java
* @run driver ClassFileInstaller -jar app.jar CheckArchivedModuleApp
* @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller -jar app.jar CheckArchivedModuleApp
* @run driver jdk.test.lib.helpers.ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes the changes from JDK-8263549 ( commit a7aba2b ) on this file

* @run driver ArchivedModuleWithCustomImageTest
*/

Expand All @@ -45,6 +42,7 @@
import jdk.test.lib.compiler.CompilerUtils;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.helpers.ClassFileInstaller;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes the changes from JDK-8263412 ( commit e834f99 ) on this file


public class ArchivedModuleWithCustomImageTest {
private static final String JAVA_HOME = System.getProperty("java.home");
Expand Down Expand Up @@ -110,7 +108,7 @@ private static void testArchivedModuleUsingImage(Path image)
String[] dumpCmd = {
customJava.toString(),
"-XX:SharedArchiveFile=./ArchivedModuleWithCustomImageTest.jsa",
"-Xshare:dump"};
"-Xshare:dump", "-Xlog:cds"};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes the changes from JDK-8233826 ( commit d1ad0ea ) on this file

printCommand(dumpCmd);
ProcessBuilder pbDump = new ProcessBuilder();
pbDump.command(dumpCmd);
Expand Down
Loading