Thursday, January 19, 2012

Where does this beep come from?

I was recently given the task of figuring out why our client application kept beeping all the time. It sounds funny but the continued noise was getting on my nerves. I searched our application for all calls to beep() on the toolkit and found nothing. Apparently, it was coming from one of our commercially purchased components that we do not have the source code for ... great. What to do now? Well I thought about trying to use AOP in some fashion to find the source of the problem but we don't have AOP currently in our application. I finally decided to do the following:
  1. Subclass MToolkit
  2. Call System.setProperty("awt.toolkit", "com.MyToolkit") to install it at startup.
  3. Set a breakpoint in my toolkit's beep() method. View the stacktrace when the beep is invoked.