我正在 eclipse 中运行一个应用程序。它产生 6 个线程。其中一个线程出现异常:
com.google.common.util.concurrent.UncheckedExecutionException: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.NullPointerException
堆栈跟踪是:null
。
我正在使用 eclipse 。并且无法完成这些步骤(调试面板提供了异常发生位置的非常顶级的功能跟踪,这对于找到根本原因没有用)。
如何调试这个异常?
我有点像 Java 新手(虽然有 C++ 经验),可能错过了一些重要信息。
这里是一些相关的代码:
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
Cache<BubbleKey, List<BlockData>> thecache;
// Above is initialized somewhere.. bit complex and code distributed across various file
//Somewhere else
List<BlockData>> __ll = thecache.getUnchecked(keydata);
以上是造成它的原因。 key 数据已正确初始化。它可能在查找/比较键函数中,但我无法到达那里,因为没有堆栈跟踪。
再来点!在某些运行中,我得到了更多的调试输出。还是不知道怎么分析。
下面的异常是一个不同的异常,在上述异常在程序中发生 3-4 次之后的后期发生。对于上述异常,正如我所提到的,从来没有任何堆栈跟踪。
at com.google.common.cache.CustomConcurrentHashMap$ComputedUncheckedException.get(CustomConcurrentHashMap.java:3305) ~[guava-10.0.1.jar:na]
at com.google.common.cache.CustomConcurrentHashMap$ComputingValueReference.compute(CustomConcurrentHashMap.java:3441) ~[guava-10.0.1.jar:na]
at com.google.common.cache.CustomConcurrentHashMap$Segment.compute(CustomConcurrentHashMap.java:2322) ~[guava-10.0.1.jar:na]
at com.google.common.cache.CustomConcurrentHashMap$Segment.getOrCompute(CustomConcurrentHashMap.java:2291) ~[guava-10.0.1.jar:na]
at com.google.common.cache.CustomConcurrentHashMap.getOrCompute(CustomConcurrentHashMap.java:3802) ~[guava-10.0.1.jar:na]
at com.google.common.cache.ComputingCache.get(ComputingCache.java:46) ~[guava-10.0.1.jar:na]
at com.google.common.cache.AbstractCache.getUnchecked(AbstractCache.java:49) ~[guava-10.0.1.jar:na]
(at myfunction.... )
最佳答案
我听起来好像您在调试中遇到了错误,您是否尝试过设置一些断点并查看是否可以准确追踪错误的来源?如果它是一个多线程应用程序,您应该考虑可以访问未初始化数据的方式,否则这些数据是不可能访问的。
关于Java 空指针异常 - 堆栈跟踪 Null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11028446/