How to determine cause of class loading

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to determine cause of class loading

Doug Simon @ Oracle
Quite often I find myself wanting to know why a given class is loaded. That is, I want to see a stack trace. As far as I can tell, there is no support for this in HotSpot which is why we hacked in support for a -XX:+TraceClassLoadingStack to graal-jvmci-8[1]. Is there a good reason a similar flag should not be added to main line HotSpot?

-Doug

[1] https://github.com/graalvm/graal-jvmci-8/commit/25de3259d10b8606e318ceecbdf0195d3b1f196f
Reply | Threaded
Open this post in threaded view
|

Re: How to determine cause of class loading

Alan Bateman


On 14/12/2017 13:20, Doug Simon wrote:
> Quite often I find myself wanting to know why a given class is loaded. That is, I want to see a stack trace. As far as I can tell, there is no support for this in HotSpot which is why we hacked in support for a -XX:+TraceClassLoadingStack to graal-jvmci-8[1]. Is there a good reason a similar flag should not be added to main line HotSpot?
>
I've needed to do this a few times, I've usually resorted to adding an
initializer to the class to dump the stack when it runs.

If something like this is added then it could be useful to specify a
pattern or even a list 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.

-Alan
Reply | Threaded
Open this post in threaded view
|

Re: How to determine cause of class loading

Doug Simon @ Oracle
That's enough input for me to open an issue ;-)

https://bugs.openjdk.java.net/browse/JDK-8193513

-Doug

> On 14 Dec 2017, at 14:30, Alan Bateman <[hidden email]> wrote:
>
>
>
> On 14/12/2017 13:20, Doug Simon wrote:
>> Quite often I find myself wanting to know why a given class is loaded. That is, I want to see a stack trace. As far as I can tell, there is no support for this in HotSpot which is why we hacked in support for a -XX:+TraceClassLoadingStack to graal-jvmci-8[1]. Is there a good reason a similar flag should not be added to main line HotSpot?
>>
> I've needed to do this a few times, I've usually resorted to adding an initializer to the class to dump the stack when it runs.
>
> If something like this is added then it could be useful to specify a pattern or even a list 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.
>
> -Alan