Is there any way to set breakpoints on all methods of a class?

JavaIntellij Idea

Java Problem Overview


Is there any way to set breakpoints on all methods of a given class?

I have a huge (2300 lines) legacy class and I need to set breakpoints on all method calls to understand how this mess works.

Java Solutions


Solution 1 - Java

You can follow the steps below:

>1. Run -> View breakpoints -> Add -> Java Method Breakpoints > >2. Class pattern -> full reference of your class (e.g., mypackage.MyClass) > >3. Method Name -> * (i.e., asterisk wild card)

Example

Solution 2 - Java

I have discovered workaround :

1. I have set "Toggle Brakepoint" hotkey to Alt+Numpad 0.
2. After that you can click on first method
3. Use "Toggle Brakepoint"
4. Alt+Down - goto Next Method. ( Alt+Up - goto Previous Method. )
5. Repeat 3 step.

Solution 3 - Java

This is similar to Sergey Senkov's answer, but without hotkeys.

In the structure view, click on the first method. Repeat the following for each method:

  1. Context Menu Key
  2. M to toggle the method breakpoint.
  3. Down

Solution 4 - Java

There is a plugin for idea: Simple Toggle All Method Breakpoint.

It allows you to breakpoint all methods / clear all method's breakpoints in one click from context menu on class in Project view.

Solution 5 - Java

As Andrey Lavrukhin suggested, there is Simple Toggle All Method Breakpoint, install it through Settings -> Plugins. Works perfectly.

Solution 6 - Java

The only way you'll be able to do what you want is to set method breakpoints on each and every method with the class in question. You need to click on the left hand gutter next to the method - a little red circle with 4 dots will appear and you may get a warning saying method level breakpoints can impact performance. You can then further configure the breakpoint (by rightclicking on it, or select shift+F8) and set it so that it breaks on entry, exit or both

I'm afraid theres no way to do this in a single step/setting.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSergey SenkovView Question on Stackoverflow
Solution 1 - JavavtsamisView Answer on Stackoverflow
Solution 2 - JavaSergey SenkovView Answer on Stackoverflow
Solution 3 - JavaGavin HaynesView Answer on Stackoverflow
Solution 4 - JavaAndrey LavrukhinView Answer on Stackoverflow
Solution 5 - JavaMirko MajkićView Answer on Stackoverflow
Solution 6 - JavaSean LandsmanView Answer on Stackoverflow