RFR 8150778: Reduce Throwable.getStackTrace() calls to the JVM

Mandy Chung mandy.chung at oracle.com
Thu Mar 3 02:18:40 UTC 2016

> On Mar 2, 2016, at 4:03 PM, Coleen Phillimore <coleen.phillimore at oracle.com> wrote:
> Freshly tested changes with jck tests, with missing checks and other changes to use the depth field, as pointed out by Aleksey.  I've kept the StackTraceElement[] allocation in Java to match the new API that was approved.
> open webrev at http://cr.openjdk.java.net/~coleenp/8150778.02_hotspot/
> open webrev at http://cr.openjdk.java.net/~coleenp/8150778.02_jdk/

typo in your link:

 80      * @since 1.9

This is not needed. Simply take this out.


215      * Native code sets the depth of the backtrace for later retrieval

s/Native code/VM/

since VM is setting the depth field.

896     private native void getStackTraceElements(StackTraceElement[] elements);

Can you add the method description
   “Gets the stack trace elements."

I only skimmed on the hotspot change.  Looks okay to me.


  43     int getDepth(Throwable t) throws Exception {
  44       for (Field f : Throwable.class.getDeclaredFields()) {
  45         if (f.getName().equals("depth")) {

You can replace the above with Throwable.class.getDeclaredField(“depth”)

Otherwise, looks okay.


More information about the core-libs-dev mailing list