<!DOCTYPE html>
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hello,</p>
    <p>when an upcall encounters a Java exception, the JVM exits, and
      prints a message and the stack trace to `System.err` [0].<br>
      The problem is when you (or libraries, ...) have used
      `System.setErr(...)` to overwrite the default stream, then you
      might not see this message and are wondering why the JVM has just
      exited without any details and without JVM crash report.</p>
    <p>Would it make sense to additionally print the message and stack
      trace directly to the `<span class="modifiers"></span><span
        class="element-name type-name-label">FileDescriptor.err` (and to
        be safe call `PrintStream#flush` and `FileDescriptor#sync`)?
        This would make sure that users see it, even if `System.err` was
        redirected.<br>
        What do you think?</span></p>
    <p><span class="element-name type-name-label">Maybe such behavior
        would be useful for all JDK code which calls `System.exit(...)`
        on a fatal error, see also
        <a class="moz-txt-link-freetext" href="https://bugs.openjdk.org/browse/JDK-8336329">https://bugs.openjdk.org/browse/JDK-8336329</a>.</span></p>
    <p><span class="element-name type-name-label"><br>
      </span></p>
    <p><span class="element-name type-name-label">Though arguably
        redirecting or silencing `System.err` might also hide other
        (non-fatal) errors, so should if possible be avoided in the
        first place. Additionally since JDK 21 there is
        `System.exit(...)` debug logging, see
        <a class="moz-txt-link-freetext" href="https://bugs.openjdk.org/browse/JDK-8302691">https://bugs.openjdk.org/browse/JDK-8302691</a> (but many users
        might not be aware of it, or might not immediately think of it
        when the JVM just exits without any details).<br>
      </span></p>
    <p>[0]
<a class="moz-txt-link-freetext" href="https://github.com/openjdk/jdk/blob/jdk-24%2B25/src/java.base/share/classes/jdk/internal/foreign/abi/SharedUtils.java#L310-L311">https://github.com/openjdk/jdk/blob/jdk-24%2B25/src/java.base/share/classes/jdk/internal/foreign/abi/SharedUtils.java#L310-L311</a><br>
    </p>
  </body>
</html>