- Do not use SYSTEM.OUT.PRINTLN as a debugging tool
- Activate and use all of the component log levels involved
- Use Log Parser to read logs
1. Conditional breakpoints
If you don't know how to add a breakpoint, just click on the left panel (preceded by the line number) and the breakpoint is created. In the debug interface, the Breakpoints view lists all the breakpoints that were created. We can add a Boolean condition to it, that is, the breakpoint will be activated and if the Boolean condition is true, the breakpoint will be executed, otherwise it will skip execution.
2. Exception Breakpoint
In the Breakpoints view, there is a j! tag button! We can use this button to add a Java exception breakpoint. For example, we want the program to continue debugging when it encounters a null pointer exception (nullpointerexception), so we can use the button to add an exception breakpoint!
3. Monitoring points
This is a very good feature when the selected property accesses or modifies the program, and the program stops execution and allows debugging. Selecting a class variable in the outline view and selecting toggle Watch from the context menu will create a property watch that will be displayed in the breakpoint (breakpoints) view as a list of all the watch points.
4. Assessment/Inspection
Press Ctrl+shift+d or Ctrl+shift+i to display the value of the selected variable or expression. We can also add permanent observers to a variable or expression, and when the program is debugging, the observers are displayed in an expression view.
5. Modifying variable values
During the debugging process, we can modify the value of the variable. Select a variable and then enter the variable view (Variables view), and enter the value in its corresponding value joins according to the variable type.
6. Stop execution inside the main function
In the Run/debug settings, the Edit Configuration dialog box has the "main" tab, and we can tick the "Stop in Main" check box. If selected, when debugging a Java program based on the main method, the program stops executing at the first line of the Main method.
7. Environment variables
Instead of adding environment variables to System properties, we can easily add them in the Edit Configuration dialog box.
8.Drop to Frame
This is one of my favorite features. During debugging, you can jump back to the beginning of the call stack frame and the value of the variable will return to the original. Depending on the depth of the stack, the main use of this feature is that all variable states can quickly return to the way the method starts executing, and then you can do it over and over again, so that you can debug multiple times in your area of interest, but there are some side effects during execution. For example, the data inserted into the database can not be deleted!
9. Distribution filtering
When we enter the (F5) method, we can also access its external libraries (such as java.*), we may not need this library, we can add a filter on the Perference tab page to exclude this package.
10. Entering, jumping and returning
I put this on the last point, during the commissioning process, these are things that must be understood (preferably mastered):
f5--Enter: Moves to the next step, if the current row has a method call, the control jumps to the first line of the called method execution.
f6--jumps: Moves to the next line. If there is a method call on the current line, it is moved directly to the next line. Does not enter inside the called method body.
f7--returns: Jumps out of the current method and continues down execution.
f8--moves to the next breakpoint to execute.
10 Debugging Tips