Question

I want to debug .class files. For example some from the JDK. I downloaded the sources and attached them.

public File[] listFiles(FilenameFilter paramFilenameFilter)
{
   String[] arrayOfString = list(); // now we here
   if (arrayOfString == null) return null;
   ....
}

Then I type F6 and move to the next line. After that, I try to watch the value of arrayOfString but I see the following:

Expression view:

Is it normal a situation? Is there a way to debug?

Update 1:

enter image description here


Update 2:

enter image description here

Update 3:

enter image description here

Était-ce utile?

La solution

The problem is that the source/class files from the JDK are compiled without debug information and therefore eclipse can't inspect these vars. See this answer for more information.

To solve your problem you need to get a different rt.jar or compile it yourself

Autres conseils

You can see all the variables values in the Variables window. Expressions will only show values when they have scopes, but sometimes they do not behave the way we want to.

So my suggestion is you should use "Variables" window to view all the variables and its value.

I recommend using ctrl+shift+i on selected expression which is inspect.

Additional option is to add Display view to your environment where you can type your own expressions and inspect those as if they're placed in code.

In the Expressions view you can enter any expression and Eclipse will try to evaluate it in the current execution context. Which means if your expression is not valid in the current context (for example, you try to evaluate object.myMethod() and object is null), you will get the error you have shown.

When this started to happen to me, it wasn't resolved by some of these solutions and it wasn't the only problem that I began to start experience.

I would like to propose another solution (for myself included). Migrate over to Android Studio as much of your workspace as you can and start familiarizing yourself with the new IDE. If developing for a company, try and get it worked into your hours to have time set aside to migrate these because some are going to be easy and some with NDK components will likely not be.

But, with Eclipse being dropped from support and the focus on Android Studio from Google it is best for us (only in my opinion of course) to start learning the new environment. It is now at a pretty stable point that it surpasses the usual Android application development side of programming over Eclipse.

yes you can, use inspect option from the menu (just below watch) by selecting the expression with mouse cursor. Be sure that you have selected the whole expression correctly.

like if below is the code

if(object.value())
{
// some code
}

so select only object.value() and right click and select inpsect

And another option is to see variable values in variable tab available

Take Windows -> Prefrences -> Java -> Complier, fom the Eclipse menubar and verify checkbox for 'Add Variable attributes to generated class files (used by the debugger) is checked.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top