Take the 2-minute tour ×

I have an application that I am working on that decided to stop working in a very unexplained manner. After some debugging and error tracing, I found the problem to be in the call to a specific method in my code.

    System.out.println("Print ");


public static void init() {

Just to clarify, calling any other methods from other classes works. Calling any methods from this specific class does not work.

Also, this class (and methods within) have always worked.

When it stopped working, I was making minor changes to something completely irrelevant in the program (As in, in a separate thread, having no effect on the class in question)

share|improve this question
what if you revert the change? –  Alvin Wong Aug 10 '12 at 3:48
This particularly innocuous system call doesn't seem to be capable of causing a hang. Go through your code judiciously with a powerful debugger and see what's going on at every step of your program call. –  Makoto Aug 10 '12 at 3:51
Does InternalPanel have any kind of static initialization? If so, please show that code. –  Paul Bellora Aug 10 '12 at 3:52
This question is way too vague. –  Bill Aug 10 '12 at 4:11
InternalPanel is this a Swing program? Should be doing all component manipulation on the AWT Event Dispatch Thread (EDT) (use java.awt.EventQueue.invokeLater and lots of boilerplate). Also mutable statics/global state is bad. / What are the other threads doing? - use your debugger, jstack, ctrl-\/ctrl-break, or similar. –  Tom Hawtin - tackline Aug 10 '12 at 4:29

3 Answers 3

up vote 2 down vote accepted

Try looking at the rest of your InternalPanel class. It's likely that something in its static initialization has an effect on something else. For example:

public class InternalPanel
    private static SomeOtherThing thing = new SomeOtherThing();

In the above code, if instantiating SomeOtherThing ends up causing a chain of events that eventually produces an infinite loop or a stack overflow, that would produce the effect you're seeing. It wouldn't actually be the call to the init function, but rather the static initialization of the InternalPanel class.

(You could easily check if this is a static initialization issue by having your test program invoke some other dummy method on the InternalPanel class.)

In debug mode, you may just want to try pausing execution at random while the program appears to be frozen, and see what code is being run and what the stack trace looks like.

share|improve this answer
Brilliant. This solved the reason why it is not working. Thank you very much! –  Joel Gallant Aug 10 '12 at 3:56

The above code works perfectly for me with just those two base classes. This is expected, as it's not really doing all that much.

I would:

  1. Perform a clean build in your IDE (mvn clean, Eclipse->(Menu)->Clean etc.)
  2. Trace (Despite what you said, I'm suggesting it anyway) to see if init() is reached.
  3. Check you don't have a static { } 'constructor' method in any other classes.
share|improve this answer

As already implied by others: What happens is, that the class InternalPanel gets loaded through the ClassLoader, if it has not been used before. That class might depend on other classes, which might get loaded and that recurses until all required classes are loaded.

For all loaded classes the static initializers are invoked. In one of those static initializers some kind of locking might be happening, causing your application to hang.

Try setting a class load breakpoint to see, if loading the class might be the issue.

share|improve this answer

Your Answer


