|
Re: Debug JDK source code [message #642295 is a reply to message #642292] |
Tue, 30 November 2010 17:37 |
Prakash G.R. Messages: 621 Registered: July 2009 |
Senior Member |
|
|
On 30/11/10 10:55 PM, Al wrote:
> I want to debug the java source code in eclipse.
>
> I am able to attach and see the JDK class files but I want to be able to
> stick a statement into the JDK source code.
> e.g. in Container.addImpl():
> System.out.println ("Container.addImpl(): " + component + "\tindex: " +
> index);
>
> I went to the rt.jar in the package explorer. I right-clicked to get
> Properties, then select Java Source Attachment and then specify a path:
> C:/Program Files/Java/jdk1.6.0_18/src.zip
> but still I get Container.class not Container.java
>
> So then unzipped the src.zip and using that directory as the source
> attachment. I can edit Container.java now in Eclipse at this point. When
> it runs it still uses the class file and the new line appears in the
> Container.class, but I don't see the output on the console.
>
> Something is still not right. How do I do this?
>
> (Note that I'm not looking for a bug in the JDK, just want to see what
> its doing)
>
Question should go to JDT forum. cc-ing.
If I'm not wrong, by attaching the source to a jar, you are merely
saying that is the source of the classes in the jar. It doesn't instruct
Eclipse to compile the source and create class files. That is done only
by having source files under the source folder.
In your case, I would put a breakpoint or a printpoint
( http://thecoderlounge.blogspot.com/2010/06/print-points-debu gging-by-writing-to.html)
That should help.
If you want a really complicated solution, I would suggest AspectJ
weaving ;-)
--
- Prakash
Platform UI Team, IBM
www.eclipse-tips.com
|
|
|
|
Re: Debug JDK source code [message #642401 is a reply to message #642295] |
Wed, 01 December 2010 08:13 |
Dani Megert Messages: 3802 Registered: July 2009 |
Senior Member |
|
|
Prakash G.R. wrote:
> On 30/11/10 10:55 PM, Al wrote:
>> I want to debug the java source code in eclipse.
>>
>> I am able to attach and see the JDK class files but I want to be able to
>> stick a statement into the JDK source code.
>> e.g. in Container.addImpl():
>> System.out.println ("Container.addImpl(): " + component + "\tindex: " +
>> index);
>>
>> I went to the rt.jar in the package explorer. I right-clicked to get
>> Properties, then select Java Source Attachment and then specify a path:
>> C:/Program Files/Java/jdk1.6.0_18/src.zip
>> but still I get Container.class not Container.java
The source attachment is only used to show the original source for the
JAR. It cannot be edited.
>>
>> So then unzipped the src.zip and using that directory as the source
>> attachment. I can edit Container.java now in Eclipse at this point. When
>> it runs it still uses the class file and the new line appears in the
>> Container.class, but I don't see the output on the console.
Probably because the launch configuration has the original rt.jar on the
class path before your source folder.
>>
>> Something is still not right. How do I do this?
Actually, you shouldn't start to mess around with the rt.jar source and
use conditional breakpoints to print out debug info.
Dani
>>
>> (Note that I'm not looking for a bug in the JDK, just want to see what
>> its doing)
>>
>
>
> Question should go to JDT forum. cc-ing.
>
> If I'm not wrong, by attaching the source to a jar, you are merely
> saying that is the source of the classes in the jar. It doesn't
> instruct Eclipse to compile the source and create class files. That is
> done only by having source files under the source folder.
>
>
> In your case, I would put a breakpoint or a printpoint
> ( http://thecoderlounge.blogspot.com/2010/06/print-points-debu gging-by-writing-to.html)
> That should help.
>
> If you want a really complicated solution, I would suggest AspectJ
> weaving ;-)
>
>
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03292 seconds