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

add support for printing a stack trace on class loading

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P4
    • 22
    • 13
    • hotspot
    • b06

    Description

      Quite often it's useful to see why a given class is loaded (e.g., trying to reduce startup time for an app by avoiding unnecessary eager class loading). One way to do this is to see a stack trace when the VM loads a class. The only possibility currently is to add a static initializer to the class of interest. However, not only is this not always possible but it doesn't correlate with class loading but with class initialization.

      In the graal-jvmci-8 fork, we added a -XX:+TraceClassLoadingStack option[1] to support this.

      [~alanb] makes a good point that If something like this is added then it could be useful to specify a pattern or even a list of class names to avoid a stack trace for every class. That might help with interference too when there is a lot of class loading going on in different threads.

      Update: See https://git.openjdk.org/jdk/pull/14553 for details on how this was implemented as an -Xlog option.

      [1] https://github.com/graalvm/graal-jvmci-8/commit/25de3259d10b8606e318ceecbdf0195d3b1f196f

      Attachments

        Issue Links

          Activity

            People

              dnsimon Douglas Simon
              dnsimon Douglas Simon
              Votes:
              3 Vote for this issue
              Watchers:
              15 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: