Community
Participate
Working Groups
I have a continual problem determining the values of variables when stopped in the debugger. There are a number of ways to do this (hovering over the variable, using Display, using Inspect, etc.). Often none of these works. Instead of getting the value, you get something like "String name - java.lang.ClassLoader.loadClass(String)," in this case for a String argument called name in java.lang.ClassLoader.loadClass(String). In the Expression view the variable name would have "name cannot be resolved" instead of a value. Other places in the same file, you get the value as desired. The above is an explicit instance where the value cannot be obtained. However, this is not a one-time thing. It happens often. It has been a perpetual problem for me with the Eclipse debugger. I use a number of debuggers, and in all of them you expect to be able to get the value of a variable, as long the program is active. (Otherwise, it is very difficult to debug what is happening.) I have been unable to determine what the conditions are for its not working. If you are not expected to be able to see a variable's value under certain conditions, then it should say that in the documentation. It would seem that if there is enough information to display the lines of code and the location of the break, then it should also know the values of the local variables. I will try to attach a GIF of a typical situation, a picture being worth a thousand words...
Created attachment 33973 [details] Screendump of being unable to obtain the value of a variable This is a situation with the debugger stopped at a breakpoint, but where hovering over the variable, name, gives its type, not its value. Display gives a similar result, and Inspect says "name cannot be resolved". Also note the Expressions view. (name is in scope, classpathEntries is not.) This instance is a method that is called often. It is important to know the value of the argument, name.
The issue here is that ClassLoader is from the system libraries and is not compiled with variable name debug attribtues. We cannot resolve a value for "name" because the class file does not provide us with the information we require (the classes in rt.jar/system libs only provide line number and source file name debug attributes).
Sorry, I am more used to working in C than Java. If what you say is true, then what I do not understand is why I can get values for some of the variables in the class and not others. In addition, I first asked this question in the newsgroups and to other Java programmers I know. I think it is safe to say that what you say is not common knowledge. However, I can research it. I am learning Java, not an expert. I assume there a reason the Eclipse code (some of it anyway) is compiled without variable name debug attribtues. Further, if what you say is the case, it would be nice to mention in the documentation that those features (inspect, etc.) won't work under those conditions. It would have saved me (and you) a lot of time. Than you for your information.
>I assume there a reason the Eclipse code (some of it anyway) is >compiled without variable name debug attribtues. These classes are not compiled by Eclipse - these are system libraries provided by the JRE you are using (likey Sun's JDK). The system libaries are pre-compiled by the JRE/JDK vendor.
Yes, the example I sent is in JDK, not Eclipse, code. I believe I have had the same problem with Eclipse code, but I need to verify that, now that I understand what is happening. In any event I see that it is not a bug in the Debugger, but rather an issue regarding retaining variable information in the distributed classes. I repeat that information about Javac debug command-line switches and the consequences is not widely known. It is not mentioned in the Java Tutorial, for example. I had difficulty in getting relevant Google hits, as well. What may be obvious to you as a person strongly involved with debuggers, is not necessarily so obvious for everyone else, especially considering "every one else" includes a wide range of levels of expertise. Even though this is not a debugger issue, I will repeat that it wouldn't hurt to put information about when Inspect, etc. will (and will not) work in the documentation. Thank you for your time and responses, and I apologize for submitting a bug report that is not a bug.
I had a similar issue with classes that were written and compiled in Eclipse (Callisto). In this particular case the class was instantiated via reflection (possibly with a Tomcat ClassLoader). In the constructor and methods called by it variables wouldn't evaluate on hover, inspect etc. and the parameters were shown in the Variables view as arg0, arg1 etc. instead of their code-level names. Could the parameter names not be taken from the source code, and the evaluations linked back to the table of variables?
The variables view displays arg0, arg1, etc., when variable names are not available as debug attributes... so we can't link them back to the source.
*** Bug 435010 has been marked as a duplicate of this bug. ***