RFR: 8193513: add support for printing a stack trace on class loading [v6]
Doug Simon
dnsimon at openjdk.org
Tue Jul 4 22:39:05 UTC 2023
> In the development of libgraal, it has been very useful to see why a given class is loaded (e.g., trying to reduce startup time by avoiding unnecessary eager class loading). One way to do this is to see the 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.
>
> This PR adds support for `-Xlog:class+load+cause` and `-Xlog:class+load+cause+native` that produce output according to a new `LogClassLoadingCauseFor` VM flag:
>
>
> product(ccstr, LogClassLoadingCauseFor, nullptr, \
> "Apply -Xlog:class+load+cause* to classes whose fully " \
> "qualified name contains this string ("*" matches " \
> "any class).") \
>
>
> Example usage:
>
> java "-Xlog:class+load+cause*" -XX:LogClassLoadingCauseFor=java.util.concurrent.ConcurrentHashMap$V --version
> [0.075s][info][class,load,cause] Java stack when loading java.util.concurrent.ConcurrentHashMap$ValuesView:
> [0.075s][info][class,load,cause] at java.util.concurrent.ConcurrentHashMap.values(java.base/ConcurrentHashMap.java:1263)
> [0.075s][info][class,load,cause] at jdk.internal.loader.NativeLibraries.find(java.base/NativeLibraries.java:102)
> [0.075s][info][class,load,cause] at java.lang.ClassLoader.findNative(java.base/ClassLoader.java:2457)
> [0.075s][info][class,load,cause] at sun.nio.fs.UnixNativeDispatcher.init(java.base/Native Method)
> [0.075s][info][class,load,cause] at sun.nio.fs.UnixNativeDispatcher.<clinit>(java.base/UnixNativeDispatcher.java:817)
> [0.075s][info][class,load,cause] at sun.nio.fs.UnixFileSystem.<init>(java.base/UnixFileSystem.java:96)
> [0.075s][info][class,load,cause] at sun.nio.fs.BsdFileSystem.<init>(java.base/BsdFileSystem.java:50)
> [0.075s][info][class,load,cause] at sun.nio.fs.MacOSXFileSystem.<init>(java.base/MacOSXFileSystem.java:52)
> [0.075s][info][class,load,cause] at sun.nio.fs.MacOSXFileSystemProvider.newFileSystem(java.base/MacOSXFileSystemProvider.java:44)
> [0.075s][info][class,load,cause] at sun.nio.fs.MacOSXFileSystemProvider.newFileSystem(java.base/MacOSXFileSystemProvider.java:37)
> [0.075s][info][class,load,cause] at sun.nio.fs.UnixFileSystemProvider.<init>(java.base/UnixFileSystemProvider.java:78)
> [0.075s][info][class,load,cause] at sun.nio.fs.BsdFileSystemProvider.<init>(java.b...
Doug Simon has updated the pull request incrementally with two additional commits since the last revision:
- use OS specific native stack printing in class load cause native stack logging
- add tests for class load cause logging
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/14553/files
- new: https://git.openjdk.org/jdk/pull/14553/files/24f8539a..c39447a7
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=14553&range=05
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=14553&range=04-05
Stats: 26 lines in 2 files changed: 23 ins; 0 del; 3 mod
Patch: https://git.openjdk.org/jdk/pull/14553.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/14553/head:pull/14553
PR: https://git.openjdk.org/jdk/pull/14553
More information about the hotspot-dev
mailing list