调试构造函数时找不到源 [英] Source not found when debugging constructor

查看:162
本文介绍了调试构造函数时找不到源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一位经验丰富的.NET和Visual Studio开发人员,他试图切换到Java和Eclipse。我是Eclipse的新手。



我很难调试我的Java程序。当我尝试进入构造函数时,逐步进入调试功能总是导致源未找到错误消息,带有编辑源查找路径按钮。我刚刚安装了Eclipse企业版,并没有混淆任何设置。



即使调试内部类也会导致此错误。考虑这个代码:

  public class HelloWorld {
public static void main(String [] args){
类JustForTesting {
public String s;
public JustForTesting(){
s =只是一个测试;
}
}
JustForTesting n = new JustForTesting();
System.out.println(Hello World!+ n.s);
}
}

如果我在第9行放置一个断点,并尝试进入构造函数(第5行),它说源未找到。窗口的标题是 Launcher $ AppClassLoader(ClassLoader).loadClass(String)line:24 非常令人难以置信的代码显然位于同一个文件中!

解决方案

这不是一个Eclipse的东西,更多的是Java的东西。当您第一次构建任何类时,Java需要加载类。如果您再次遇到这种情况,只需执行一步退回(这将完成加载该类),然后再次执行(这将进入您的构造函数)。


I am an experienced .NET and Visual Studio developer who's trying to switch to Java and Eclipse. I am a newbie to Eclipse.

I am having a hard time debugging my Java programs. The "step into" debugging function always results in a "Source not found" error message with an "Edit Source Lookup Path" button whenever I try to step into a constructor. I've just installed Eclipse Enterprise Edition and not messed around with any settings.

Even debugging inner classes results in this error. Consider this code:

public class HelloWorld {   
  public static void main(String[] args) {
        class JustForTesting {
        public String s;
        public JustForTesting() {
        s = "Just a test";
        }
    }   
    JustForTesting n = new JustForTesting();
     System.out.println("Hello World! " + n.s);
  }
}

If I put a breakpoint at line 9 and try to step into the constructor (line 5) it says "Source not found". The title of the window is Launcher$AppClassLoader(ClassLoader).loadClass(String) line: 24 Quite unbelievable as the code obviously resides in the same file!

解决方案

It's not so much an Eclipse thing and more of a Java thing. When you construct any class for the first time Java needs to load the class. If you get into that situation again just do a step-return (this will finish loading the class) and then do step-into again (this will go into your constructor).

这篇关于调试构造函数时找不到源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆