How to view everything that works in the event stream

We are experiencing a mistake with which we cannot track where something freezes our swing-stream (it was almost 2 weeks and no real results) - we are experienced Swing programmers, but we have a huge program, and we think that it some of the legacy code

I am wondering if there is any way outside of editing the actual EventQueue class in the JDK that will allow us to view all the parts of our code that are currently running in the Dispatch Event thread - perhaps some kind of tool that will allow us to view things when Do they enter or leave the event dispatch stream?

+4
source share
4 answers

One interesting approach is to extend EventQueue and push() , as shown here .

+5
source

Recording everything that passes through the stream of events seems like a cumbersome way to diagnose freezing. Wouldn't it be easier to wait until a problem arises, and then ask β€œEvent Manager,” what is he doing now? One way to do this is to enable JMX monitoring , connect to your running process using a JMX client such as VisualVM (which comes with the JDK), wait for the problem to appear, and then take a stream dump .

If you still want to register everything that happens in the Event Dispatch Thread, you can do this:

  • In Eclipse, run the application in debug mode.
  • Create a breakpoint on EventQueue.dispatchEvent , right-click it, select "properties", check "condition" and enter the following "condition":

     System.out.println(arg0); return false; 
+4
source

It might be nice to try BTrace for the EventQueue tool and track stack traces every time something is added. I think the latest VisualVM has plugins that allow you to control the running JVM using the BTrace script.

+2
source

If you are using Oracle JRE, TracedEventQueue is already included. You can install it as above:

 EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue(); eventQueue.push(new TracedEventQueue()); 

Please note that this will output the output of the lot ...

0
source

All Articles