回应Can Java's NullPointerException be changed to report on which variable was null? thorbjorn-ravn-andersen说:
No, the debug information in the class file does not contain enough information to allow this.
我的问题是,为什么不呢?
最佳答案
它可能根本不是一个变量:它可能是一个临时结果,例如方法调用的结果。当 NPE 发生时,它只是一个匿名堆栈槽。
关于java - 为什么类文件不包含足够的信息来提供 NPE 中为空的指针的名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14129455/