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

Adjust fillInStackTrace filtering to assist 6998871

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • hs21
    • hs21
    • hotspot
    • None
    • b09
    • generic
    • generic
    • Not verified

        When an exception is created, fillInStacktrace is called to populate the backtrace information. This is done in java_lang_Throwable::fill_in_stack_trace in the VM. Because the interesting part of the stacktrace is from the location where the exception was created, and upwards, filtering is applied in fill_in_stack_trace to remove the entry for fillInStackTrace() itself, and the exception constructors.

        The current filtering code only expects to find a single frame for the fillInStackTrace method, so if an exception class overrides fillInStackTrace (and invokes super.fillInStackTrace) this actually disables the filtering of the constructors. Eg we see:

        Exception in thread "main" MyException
                at MyException.fillInStackTrace(MyException.java:3)
                at java.lang.Throwable.<init>(Throwable.java:260)
                at java.lang.Exception.<init>(Exception.java:54)
                at java.lang.RuntimeException.<init>(RuntimeException.java:51)
                at MyException.<init>(MyException.java:1)
                at MyException.main(MyException.java:7)

        instead of:

        Exception in thread "main" MyException
                at MyException.main(MyException.java:7)

        The changes to Throwable.java for 6998871 effectively introduce an additional fillInStackTrace() frame and so this too disables the desired filtering of the backtrace.

        The proposal is quite simple: to modify fill_in_stack_trace so that it expects one or more fillInStackTrace frames, followed by zero or more constructor frames. This addresses the needs of 6998871 as well as fixing any user-defined overriding of fillInStackTrace.

              dholmes David Holmes
              dholmes David Holmes
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: