6

I am using Eclipse 3.5 and I attached the src.zip to my global settings in Eclipse. Windows--> Preferences -->Java -->Installed JREs -->rt.jar - Source attachment - ...../jdk/src.zip

I am successfully able to step in the java core library .class files and view the source code. I building a Class which uses the LinkedList and I have set a breakpoint inside the LinkedList class.

When I debug the breakpoints in my source code (my projects) are working good but when I need to step into the java core lib .classes I get the following error in my Eclipse eclipse error

Unable to install breakpoint in java.util.LinkedList due to missing line Number attributes. Modify complier options to generate line number attributes.

I checked my complier settings in Preferences and found all options checked true. enter image description here It would to great if someone can help me resolve this issue.

Thanks in advance.

Akh
  • 5,961
  • 14
  • 53
  • 82

3 Answers3

7

You may have the compiler set to include debugging information in YOUR class files, but the class files in rt.jar weren't compiled that way. You need to either recompile all the source for the classes in rt.jar (not for the faint of heart), or download a debug build of the jdk.

David Conrad
  • 15,432
  • 2
  • 42
  • 54
  • Worked like a charm. Thank you very much. Has been searching for this. – Akh Mar 13 '11 at 19:29
  • Hi David... Can you tell how to make changes in the Java core .classes and compile them and to be used by my project? For Eg: I want to modify the private variable -- header -- into a public to assign values in the LinkedList class for my research purpose? I studying the behavior of LinkedList... Would Appreciate even if u point me to some resources. – Akh Mar 13 '11 at 19:47
  • I don't think that's a good idea, and if you just want to access private variables for research you can do it through reflection. For example, minus the exception handling: List list = new LinkedList(); list.add("foo"); Field header = list.getClass().getDeclaredField("header"); header.setAccessible(true); System.out.println(header.get(list)); – David Conrad Mar 14 '11 at 02:30
  • Thank you David. Let me try that. – Akh Mar 14 '11 at 02:43
  • @DavidConrad........ "You need to either recompile all the source for the classes in rt.jar (not for the faint of heart)" ..can you please guide on this...pointers plz.. – lowLatency Apr 22 '12 at 07:34
  • @jain007 Is there some reason why you cannot just download a debug build of the JDK? I have never personally recompiled the Java class library sources. It really shouldn't be necessary since Oracle provides debug builds on the download page. – David Conrad May 09 '12 at 01:31
  • @DavidConrad ok, but i am not able to see any stuff reg debug build on the link you mentioned above (http://www.oracle.com/technetwork/java/javase/downloads/index.html) request you to guide me on this – lowLatency May 09 '12 at 09:22
  • I'm sorry, I don't know where they've moved the downloads to. – David Conrad Jun 09 '12 at 05:03
2

This blog posts give a comprehensive list of points to check

Follow the steps if you are compiling using Eclipse IDE

enter image description here

  1. Go to windows > preferences > Java > compiler screen.
  2. Make sure that add line number attributes to generated files (used by debugger) check box is checked.
  3. Build again and try adding a breakpoint ahd hope it should work for you.

Note for ant builds

Follow the steps if you are compiling using ANT utility:

  1. Check the build.xml file and make sure that debug attribute is set to true in javac task
  2. Also, if you are using JBoss as an app server, then make sure that you have already opened a port for socket binding of remote machine connection. If not then just ensure that C:/jboss/bin/run.bat has an entry with:
    "set JAVA_OPTS=%JAVA_OPTS% -Xdebug –Xrunjdwp:transport=dt_socket,address=5000,server=y,suspend=n" for opening port 5000 to listen all socket connections for debug/remote java application.
  3. Build again and try adding a breakpoint ahd hope it should work for you.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
2

You should not use a JRE with a JDR src attached as the JRE classes are not well suited for debugging.

Let Eclipse search for Java environments and then select the JDK from the resulting list. This Java environment will have the src.zip attached correctly and you should be able to investigate.

Note that even JDK classes do not have full debugging information available, so you cannot see local variables etc.

(Also, the Compiler settings panel only applies to your code. The JRE classes are pregenerated and the panel does not influence them).

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347