diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index f5dcb44db2b79..1914a8dcbd582 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -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 @@ -145,6 +145,7 @@ public Map call() { vmOptFinalFlags(map); dump(map.map); + dumpFlags(); log("Leaving call()"); return map.map; } @@ -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 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. *