Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8338428: Print final VM flags for task #23054

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
34 changes: 33 additions & 1 deletion test/jtreg-ext/requires/VMProps.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2025, 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 @@ -145,6 +145,7 @@ public Map<String, String> call() {
vmOptFinalFlags(map);

dump(map.map);
dumpFlags();
log("Leaving call()");
return map.map;
}
Expand Down Expand Up @@ -696,6 +697,37 @@ private boolean checkProgramSupport(String logString, String cmd) throws IOExcep
return (exitValue == 0);
}

private void dumpFlags() {
log("dumpFlags() entering:");
try {
String testJdk = System.getProperty("test.jdk");
String toolName = "java" + (Platform.isWindows() ? ".exe" : "");
Path javaPath = Paths.get(testJdk, "bin", toolName);

String options = System.getProperty("test.vm.opts", "")
+ System.getProperty("test.java.opts", "");
ArrayList<String> args = new ArrayList<>();
args.add(javaPath.toAbsolutePath().toString());
Collections.addAll(args, options.trim().split("\\s+"));
args.add("-XX:+PrintFlagsFinal");
args.add("-version");
ProcessBuilder pb = new ProcessBuilder(args);
File output = new File("jvm.flags.final.log");
pb.redirectOutput(output);
pb.redirectErrorStream();
Process p = pb.start();
p.waitFor(120, TimeUnit.SECONDS);

log("The test jvm options: " + options);
log("The final jvm flags are saved to: " + output.getAbsolutePath());
} catch (Throwable t) {
log("Erro while printing JVM flags " + t.getMessage());
}

log("dumpFlags() leaving:");
}


/**
* Checks musl libc.
*
Expand Down