aspose file tools
The moose likes Java in General and the fly likes debuging a static block Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "debuging a static block" Watch "debuging a static block" New topic
Author

debuging a static block

sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 643
when i am tring to debug a class which contain a static block it doesn't going to static block?
why is that?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32651
    
    4
Don't know. Please show us the details of your static block.
sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 643
there is some problem with showing the code,
anyway i need to know when we doing debuging is it going t the static blocks niormally?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Are you saying that the static block executes when not debugging, but doesn't when debugging?
Ilya Kalujny
Greenhorn

Joined: Mar 20, 2008
Posts: 9
aruna sameera wrote:when i am tring to debug a class which contain a static block it doesn't going to static block?
why is that?


AFAIK, static block is executed when class is first loaded by class loader. Silly suggestion: you have break-point set when this happens?
syruss kumar
Ranch Hand

Joined: Jul 23, 2009
Posts: 87
you are right the control will go inside the static block normally while we debug the code.Jus try this.

1.Just put a break point in side the static block and inside test().The control will stay in static block.
2.Then remove the break point from static block and try.the control will stay in test() by printing "Inside static block" .
because the class loader executes static block while the class is created .




All search starts with beginner's luck and all search ends with victor's severly tested.
sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 643
Thanks syruss kumar .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: debuging a static block
 
Similar Threads
static block or initialisation block
initialization sequence - what is done first?
absctract class
What is the use of static block
static synchronized block