“Unknown Source” in java stack trace, yet line numbers are in the class file

后端 未结 4 495
南方客
南方客 2020-12-25 13:05

I\'ve written a super simple java class that is throwing exceptions as it should. However the stack trace I\'m getting looks like this:

java.lang.RuntimeExc         


        
相关标签:
4条回答
  • 2020-12-25 13:30

    I think the correct way is:

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

    Note there are no spaces between lines,vars,source

    0 讨论(0)
  • 2020-12-25 13:36

    Found this answer on another question:

    This is normally related to missing debug information. You are probably using JRE (not JDK), which does not include debug information for rt.jar classes. Try using full JDK, you'll get proper locations in the stack trace

    0 讨论(0)
  • 2020-12-25 13:43

    I had exactly the same problem. In our environment it helped to switch off the optimize-flag:

    <javac optimize="off" ...
    

    Apparently Ant does not ignore attribute optimize, although Ant-Doc says for Attribute "optimize" (and we are using Java 1.7):

    Indicates whether source should be compiled with optimization; defaults to off. Note that this flag is just ignored by Sun's javac starting with JDK 1.3 (since compile-time optimization is unnecessary).

    0 讨论(0)
  • 2020-12-25 13:45
    <property name="srcdir" location="src/"/>
    <property name="builddir" location="build/"/>
    <target name="compile">
      <exec executable="javac">
        <arg value="${srcdir}/*" />
        <arg value="-d" />
        <arg value="${builddir}"/>
      </exec>
    </target>
    
    0 讨论(0)
提交回复
热议问题