Paul Reiners
Paul Reiners

Reputation: 7886

Setting a breakpoint for when a Java class is loaded in IntelliJ IDEA

Is there a way to set a breakpoint for when a particular Java class is loaded in IntelliJ IDEA?

Upvotes: 4

Views: 4341

Answers (2)

Tony
Tony

Reputation: 1173

In 2016 version it works by setting the breakpoint to the class definition line (public class YourClass ...). You don't have to use explicit constructor, it stops when ... new YourClass(); is called.

Upvotes: 3

fo_x86
fo_x86

Reputation: 2613

Not that I know of. But if you are trying to determine from where a class is first being loaded, you could put a break point in the constructor (or static fields/block) of the class, and look at the stack trace. That should tell you where the first call to the class is being made.

Upvotes: 2

Related Questions