java - 断点命中 Hashmap.put() 一个简单的 Hello World 程序

标签 java debugging breakpoints

程序简单:

public class HelloWorld {
    public static void main(String args[]){
       System.out.println("Hello World");
    }
}

现在我在 HashMap.class 中的函数 put(K key, V value) 中设置断点

public V put(K key, V value) {
    if (table == EMPTY_TABLE) {
        inflateTable(threshold);
    }
    if (key == null)
        return putForNullKey(value);
    int hash = hash(key);

然后我开始调试HelloWorld.class,它会遇到HashMap中的断点。奇怪的是怎么会在HashMap中遇到put()
我试过HashMap,Hashtable,它们都是一样的。

最佳答案

这是我在重现您的场景时获得的堆栈跟踪。

当应用程序被 Eclipse 启动时,它不会简单地进入 Main 函数。在创建实例之前,您的类需要加载到 JVM 中。为此,将使用类加载器

在您的例子中,URLClassLoader 有一个 URLClassPath 类型的成员,使用一个 HashMap 对象

enter image description here

关于java - 断点命中 Hashmap.put() 一个简单的 Hello World 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34117180/

相关文章:

c# - 当前不会命中断点。尚未在 Unity 中为此文档加载任何符号

Eclipse 调试器错误 : Evaluations must contain either an expression. ..

java - 在从sql数据库列表中检索到的新记录中添加

java - 识别多线程 MQTT 发布者中的瓶颈

java - 在 property.setProperty ("mail.smtp.host",host) 中出现语法错误;

asp.net - Global.asax : 'RedirectPermanent' is not a member of 'System.Web.HttpResponse' 中的错误

linux - 好的 Linux 汇编语言调试器?

java - 访问谷歌日历时出现空指针异常

c - Windows触发了一个断点——C语言

java - 具有重复属性的 Spring Boot 多个数据源