I'm trying to debug a Null Pointer Exception in java, but the stack trace is being unhelpful. It can't point me to anything in particular:
[exec] Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
[exec] at core.InputPanel.&开发者_开发百科lt;init>(Unknown Source)
[exec] at core.Main.<init>(Unknown Source)
How can I narrow down where this null pointer might be?
You have compiled your source code without debug information; e.g. javac -g:none ...
. Compile with debug information (e.g. javac -g ...
) and the stack traces will be more informative.
Here are some references:
- The
javac
manual page. - The
javac
target in the Ant manual. - The Maven compiler plugin documentation.
(FWIW, the default behaviour of the Java compilers ... with no -g
options ... is to include source file names and line numbers. So you something in your build scripts is doing something to leave out the debug information. This is good for minimizing the size of your class / JAR files, but it is bad for debugging.)
Check the constructor of core.InputPanel
. There is null-reference access. Check that all object-references are non-null in the constructor.
精彩评论