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