Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8302691

System.exit and Runtime.exit debug logging

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P3
    • 21
    • core-libs
    • None
    • behavioral
    • minimal
    • Hide
      There is no change to the API or specification.
      The change in behavior only occurs if the logger is enabled with Level.DEBUG.
      Show
      There is no change to the API or specification. The change in behavior only occurs if the logger is enabled with Level.DEBUG.
    • Other
    • Implementation

    Description

      Summary

      Calls to java.lang.Runtime.exit(status) are logged to the System logger, if enabled.

      Problem

      It can be difficult to identify the cause of calls to java.lang.System.exit(status) and Runtime.exit(status) because the Java runtime exits immediately. Logging a message and stack trace makes it easier to locate the caller and cause.

      Solution

      A call to the system logger (java.lang.System.getLogger) is added to the implementation of Runtime.exit(status) before shutdown commences. If the logger named `java.lang.Runtime' is configured with level System.Logger.Level.DEBUG, a message is logged including the status and stack trace.

      Also add an @implNote to java.lang.System.exit(int) to note the behavior of Runtime.exit(int).

      The configuration of the system logger determines how the message appears in the logs or on the console.

      Specification

      There is no change to the API or specification. The logging is documented as an @implNote describing the implementation behavior.

      The java.lang.Runtime.exit(int) javadoc has an added implNote:

       * @implNote 
       * If the {@link System#getLogger(String) the system logger} for {@code java.lang.Runtime}
       * is enabled with logging level {@link System.Logger.Level#DEBUG Level.DEBUG} the stack trace
       * of the call to {@code Runtime.exit()} is logged.

      The java.lang.System.exit(int) javadoc has an added implNote:

       * @implNote
       * The initiation of the shutdown sequence is logged by {@link Runtime#exit(int)}.

      Attachments

        Issue Links

          Activity

            People

              rriggs Roger Riggs
              rriggs Roger Riggs
              Alan Bateman
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: