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

make Throwable.backtrace visible to Class.getDeclaredField again

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 9
    • hotspot
    • b116
    • generic
    • generic

      Currently Throwable.backtrace is treated by Class.getDeclaredField like an injected field; it is not reported back to the caller. The reason it is hidden is because a crash that was reported (JDK-4496456) when a user tries to get the contents of the backtrace Object array.

      Without knowing the history here JDK-4496456 was very likely because of the specific representation behind Throwable.backtrace back then. This changed. The Object[] looks now like:

      Object[] backtrace = { short[] method_ids, int[] bcis, Object[] mirrors };

      and it's perfectly sane to do:

              // Retrieve the class of throwable.backtrace[0][0].
              Class class2 = ((Object[]) ((Object[]) backtrace)[0])[0].getClass();

      (although it will bail out with a ClassCastException).

      To make sure this doesn't break again we could take the test case of JDK-4496456 and make a regression test.

            coleenp Coleen Phillimore
            twisti Christian Thalinger (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: