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

Add OnException diagnostic JVM option

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P3 P3
    • 10
    • 9
    • hotspot

      This is an enhancement request to add a new JVM option 'OnException' that can be used to trigger some action when a given Java exception is encountered by the process.

      We already have AbortVMOnException which when enabled aborts the
      JVM generating hs_err and core file when the specified exception occurs. e.g.
      java -XX:+UnlockDiagnosticVMOptions -XX:AbortVMOnException=InvalidClassException -XX:AbortVMOnExceptionMessage="class invalid for deserialization"

      The idea is to add a more generic option OnException that upon the occurrence of a specified exception can run -

      (a) generic commands, like:
      -XX:OnException=exception=InvalidClassException,message="class invalid for deserialization",cmd="kill -9 %p"

      (b) can also accept some pre-defined actions like dumpJfr, dumpCoreAndAbort, dumpCoreAndContinue, dumpHeap, dumpThreads etc.
      -XX:OnException=exception=InvalidClassException,message="class invalid for deserialization",action=dumpJfr

      This would be very useful in troubleshooting the Java/JVM failures that just result in printing the exception message and stack trace, and where we need more data to investigate the problem.

            Unassigned Unassigned
            poonam Poonam Bajaj Parhar
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: