Skip to content

Commit 8aed51e

Browse files
committed
Add comment
1 parent 4b4d5a6 commit 8aed51e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

  • distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers

distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers/JvmErgonomics.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ static Map<String, Optional<String>> finalJvmOptions(
7777
}
7878

7979
private static List<String> flagsFinal(final List<String> userDefinedJvmOptions) throws InterruptedException, IOException {
80+
/*
81+
* To deduce the final set of JVM options that Elasticsearch is going to start with, we start a separate Java process with the JVM
82+
* options that we would pass on the command line. For this Java process we will add two additional flags, -XX:+PrintFlagsFinal and
83+
* -version. This causes the Java process that we start to parse the JVM options into their final values, display them on standard
84+
* output, print the version to standard error, and then exit. The JVM itself never bootstraps, and therefore this process is
85+
* lightweight. By doing this, we get the JVM options parsed exactly as the JVM that we are going to execute would parse them
86+
* without having to implement our own JVM option parsing logic.
87+
*/
8088
final String java = Path.of(System.getProperty("java.home"), "bin", "java").toString();
8189
final List<String> command =
8290
Stream.of(Stream.of(java), userDefinedJvmOptions.stream(), Stream.of("-XX:+PrintFlagsFinal"), Stream.of("-version"))

0 commit comments

Comments
 (0)