Java Stack Traces: Unknown Source

If you get a stack trace with “Unknown Source” like below…

Exception in thread "main" java.lang.NumberFormatException: For input string: "3.1415" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:580) at ExampleCli.parseNumericArgument(Unknown Source) at ExampleCli.parseCliOptions(Unknown Source) at ExampleCli.main(Unknown Source)

…it means that the program lacks the relevant debugging information. Specifically the class files are missing the LineNumberTable attribute (JVMS 4.7.12).

Possible reasons

  • The code has been compiled with the -g:none javac option.

  • The class files has been processed by an obfuscator or minimizer

Solution

  • Make sure you’re using the JDK classes and not the JRE classes (if the lines refer to classes in the standard API)

  • Recompile with debug information. If the lines refer to some third party library for which you don’t have access to the source code, you’re out of luck.

Comments

Be the first to comment!