且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java错误:EventDispatchThread.run()行:不可用[局部变量不可用]

更新时间:2022-10-19 15:58:07

在Eclipse中:右键单击该项目,然后选择属性



以下是您必须更改的设置:





另外,使用运行>运行配置... ,选择选项卡,并确保当前项目位于源列表中。如果没有,请点击添加...> Java Project ...


I get the following error when I try to start my code in the debugger.

EventDispatchThread.run() line: not available [local variables unavailable]

The code is very large and I can't publish it here but anyway here are some details:

This statement seems to crash and I can't step into the constructor with the debugger:

Satellite satellite = new Satellite();

When I put a breakpoint on this line and try to step into the constructor or step over I get the same error as above.

Here are parts of Satellite class implementation:

package tags;

import main.*;
import xml.*;

public class Satellite extends XMLElement {

    public static final String[] ATTRIBUTES = {
        "XmlFileVersion",
        "SatelliteName",
        "xmlns:xsi=@xmlns_xsi",
        "xsi:noNamespaceSchemaLocation=@xsi_noNamespaceSchemaLocation"
    };

    public Satellite() {
        super(ATTRIBUTES);
        setTopLevelElement();

        setAttribute("XmlFileVersion",ValueCenter.Satellite_XmlFileVersion());
        setAttribute("SatelliteName",ValueCenter.Satellite_SatelliteName());
        addElement(new SubSystemList());
    }
}

I localized the problem somewhere in the line addElement(new SubSystemList()); . I added a breakpoint here and again tried to step in or step over and now I got a ClassNotFoundException. The debug cursor jumps to an empty window where "Source not found." is written but the Source is 100% available and I also got the corresponding .class files. The other thing is that the Eclipse IDE throws no errors on the syntax check.

I don't understand this. What can cause these errors and why can't I use the debugger to walk through the method calls?

I've updated the Eclipse Helios SR1 for Java Devs and installed the latest java version on my pc.

I know that the code has an endless loop anywhere in here because I get an ***Error Exception if I run it without the debugger. But anyway, shouldn't it be possible to debug through the code, to investigate the real problem? Why is the debugger crashing with other errors or exceptions than a non debugger run?

btw: only one thread and sequential execution.

Hope someone can help.

Edit 1:

Some additional infos. My Workspace has two projects. In one there is the main program with the Satellite and others. In the other project I have many supporting classes like this XMLElement. This structure works for many classes.

By the way: I can step into the XMLElement.setAttribute method but I can't step into the XMLElement.addElement.

The other strange thing is that Satellite is in the same project as the main class but it's also not possible to step into the constructor.

Maybe this helps?

In Eclipse: Right-click the project and select Properties.

Here are the settings you have to change:

Also, find your Run Configuration using Run > Run Configurations ..., select the Source tab and make sure the current project is in the sources list. If not, click Add... > Java Project ...