Showing posts with label debugging. Show all posts
Showing posts with label debugging. Show all posts

Wednesday, February 19, 2014

How to find the Class/Object which invoke a method ?


Throwable t = new Throwable(); 
StackTraceElement[] elements = t.getStackTrace(); 
String calleeMethod = elements[0].getMethodName(); 
String callerMethodName = elements[1].getMethodName(); 
String callerClassName = elements[1].getClassName(); 

Tuesday, February 11, 2014

How to put Conditional Breakpoints in Netbeans.

Conditional Breakpoints in NetBeans

As of NetBeans 6.x, most types of breakpoints (line, method, field, exception) can be conditioned by a user defined expression.
The expression is evaluated in the place of breakpoint hit and must be of boolean type.

Examples of conditions:
  • x > 1 && y < 10
  • text.equals(name)

In order to modify these conditions, open the "Breakpoint Properties" dialog using one of these methods:
  • Right-click the breakpoint and click Breakpoint > Properties
  • Open the Breakpoints window, right-click on the breakpoint and select Properties