I’m very glad that I’ve reached The Fourth Milestone set up by Jordan. Bug 256185 is about NullPointerException. Here are the steps that I took to locate the code that throws this exception.
1. A stack trace from the JVM was attached to the Bug Report. This gave me a very good starting point. I checked out the org.eclipse.wst.wsdl.ui component from the CVS repository. (Although I did set the Plug In Development Target Platform correctly, I got error messages from the compiler on the development platform. After inspecting the error messages, I also checked out the org.eclipse.wst.wsdl component. All the error messages then disappeared. This second component was not related to the bug, however.)
2. Following the stack trace, I tinkered with the org.eclipse.wst.wsdl.ui.internal.asd.design.directededit.ASDCCombo class. I added a comment and inserted one System.out.prinltn statement. When I tried to run this class with the target platform, I encountered a strange problem – the WSDL editor was not invoked at all. I posted my problem and some screenshots to the webtools newsgroup. With Valentin’s advice, I found out that it was indeed caused by inconsistent versions between the source code(checked out from HEAD) and the target platform(3.1M4 build). Thus I downloaded and installed the 3.1M5 build that was released in early February. Everything was running smoothly since then.
3. Following the stack trace again, I inserted a few System.out.println statements in two methods, namley dropDown and popupEvent. I found it interesting to see some output displayed in the console view on the development platform. Then I realized that I could not use the line numbers in the stack trace since I had added some comments and statements to those methods. I felt a kind of stupid. Now I had to find a way to get an updated stack trace on the basis of the class that I had modified. I posted my question to the Bug Report. Valentin showed me how to access the stack trace on the target platform. It’s a very useful technique.
4. I ran the ASDCCombo class with the target platform again. Then I reproduced the bug on the target platform instance. Following Valentin’s advice, I went through this sequence of selections: Window > Show View > Other > Erro Log. I saw the stack trace in the Event Details dialog box. This time I used the line number in the stack trace to locate the code on the development platform. In order to confirm that this was the line of code that threw the NullPointerException, I inserted a line of code:
System.out.println( “oh boy – text is null” ). I ran the class again. The output in the console view on the development platform was consistent with the stack trace (the Error Log) displayed on the target platform.
From hindsight, I could have located the code quite quickly if I did not tinker with the source code I checked out from the CVS repository. I was very near to finding the code when I had the stack trace on hand. However, I didn’t regret from “playing with the code.” I have acquired some knowledge regarding the inner workings of the WTP platforms. I have also found Valentin to be very supportive when I posted my questions at the webtools newsgroup and Bugzilla(i.e. the Bug Report). Finally I was amazed by Tony Lai’s comment to my blog posting. He’s working on a Mozilla project and has used exceptions to track down a bug. Last but not the least, after going around the circle, I’ve built up my confidence in fixing WTP bugs.
Here are three screenshots: