java的stack错误没有显示行号显示unknown source

Life is short , play more!
本文来自lihao's Blog,转载请注明。

通常我们调试代码的时候,通过异常的错误输出,根据exception stack的信息,来进行定位可能存在的错误位置。 exception stack其中有代码的名称,以及行号信息。 但有时候发现, 行号信息无法显示,却提示unknown source。找不到源代码? 其实这里提示的需要源代码是不准确的。其实我们不需要源代码,只是需要编译的时候打开debug 开关。

Warning: corrupted config fileException in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError
at Form.HouseCalc.<init>(HouseCalc.java:80)
at Form.HouseCalc$61.run(HouseCalc.java:1644)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at Form.HouseCalc.error(HouseCalc.java:1611)
at Form.HouseCalc$1.write(HouseCalc.java:72)
at java.io.PrintStream.write(Unknown Source)
at sun.nio.cs.StreamEncoder.writeBytes(Unknown Source)
at sun.nio.cs.StreamEncoder.implFlushBuffer(Unknown Source)
at sun.nio.cs.StreamEncoder.flushBuffer(Unknown Source)
at java.io.OutputStreamWriter.flushBuffer(Unknown Source)
at java.io.PrintStream.write(Unknown Source)
at java.io.PrintStream.print(Unknown Source)
at java.io.PrintStream.println(Unknown Source)
at Lib.Files.Properties.loadProperties(Properties.java:46)
at Lib.Files.Properties.<clinit>(Properties.java:31)
... 16 more

ant如何打开debug

在javac的定义中,设定如下

debug="true" debuglevel="lines,vars,source"

发表评论

电子邮件地址不会被公开。 必填项已用*标注