diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGeneratorRunner.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGeneratorRunner.java index f2769768975f..7598c09d52d5 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGeneratorRunner.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGeneratorRunner.java @@ -714,11 +714,10 @@ private static void reportUserException(Throwable e, OptionValues parsedHostedOp } else { reportUserError(e.getMessage()); } - Throwable current = e.getCause(); - while (current != null) { + Throwable cause = e.getCause(); + if (cause != null) { System.out.print("Caused by: "); - current.printStackTrace(System.out); - current = current.getCause(); + cause.printStackTrace(System.out); } if (parsedHostedOptions != null && NativeImageOptions.ReportExceptionStackTraces.getValue(parsedHostedOptions)) { System.out.print("Internal exception: ");