< prev index next >
test/hotspot/jtreg/runtime/NMT/CheckForProperDetailStackTrace.java
Print this page
@@ -26,16 +26,19 @@
* @bug 8133747 8218458
* @summary Running with NMT detail should produce expected stack traces.
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
+ * @compile ../modules/CompilerUtils.java
* @run driver CheckForProperDetailStackTrace
*/
import jdk.test.lib.Platform;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* We are checking for details that should be seen with NMT detail enabled.
@@ -47,10 +50,15 @@
* This information does not change often enough that we are concerned about the
* stability of this test - rather we prefer to detect changes in compiler behaviour
* through this test and update it accordingly.
*/
public class CheckForProperDetailStackTrace {
+ private static final String TEST_SRC = System.getProperty("test.src");
+ private static final String TEST_CLASSES = System.getProperty("test.classes");
+
+ private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
+ private static final Path MODS_DIR = Paths.get(TEST_CLASSES, "mods");
/* The stack trace we look for by default. Note that :: has been replaced by .*
to make sure it matches even if the symbol is not unmangled.
*/
private static String stackTraceDefault =
@@ -81,15 +89,28 @@
/* A symbol that should always be present in NMT detail output. */
private static String expectedSymbol = "locked_create_entry";
public static void main(String args[]) throws Exception {
+ boolean compiled;
+ // Compile module jdk.test declaration
+ compiled = CompilerUtils.compile(
+ SRC_DIR.resolve("jdk.test"),
+ MODS_DIR.resolve("jdk.test"));
+ if (!compiled) {
+ throw new RuntimeException("Test failed to compile module jdk.test");
+ }
+
+ // If modules in the system image have been archived in CDS, they will not be
+ // created again at run time. Explicitly use an external module to make sure
+ // we have a runtime-defined ModuleEntry
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-XX:+UnlockDiagnosticVMOptions",
"-XX:NativeMemoryTracking=detail",
"-XX:+PrintNMTStatistics",
- "-version");
+ "-p", MODS_DIR.toString(),
+ "-m", "jdk.test/test.Main");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
// We should never see either of these frames because they are supposed to be skipped.
< prev index next >