diff --git a/distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers/SystemJvmOptions.java b/distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers/SystemJvmOptions.java index f255f9a35fd..dd84a30c9e3 100644 --- a/distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers/SystemJvmOptions.java +++ b/distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers/SystemJvmOptions.java @@ -55,6 +55,8 @@ final class SystemJvmOptions { * debugging. */ "-XX:-OmitStackTraceInFastThrow", + // enable helpful NullPointerExceptions (https://openjdk.java.net/jeps/358), if they are supported + maybeShowCodeDetailsInExceptionMessages(), // flags to configure Netty "-Dio.netty.noUnsafe=true", "-Dio.netty.noKeySetOptimization=true", @@ -69,6 +71,14 @@ final class SystemJvmOptions { ); } + private static String maybeShowCodeDetailsInExceptionMessages() { + if (JavaVersion.majorVersion(JavaVersion.CURRENT) >= 14) { + return "-XX:+ShowCodeDetailsInExceptionMessages"; + } else { + return ""; + } + } + private static String javaLocaleProviders() { /** * SPI setting is used to allow loading custom CalendarDataProvider