Reputation: 483
When an exception is thrown by code that is compiled within a jar that doesn't have a source jar attached to it, do the line numbers in the stacktrace refer to the line numbers of the bytecode statements in the compiled class, or somehow the line number in the class containing the source code?
Upvotes: 1
Views: 1171
Reputation: 109264
When you compile Java code, the line numbers of the source are by default written into the bytecode. This makes it easier to track down problems. The line number (and source file) information is stored in the .class
file, and is not (necessarily) the same as the line in attached sources. For example, if you attach the sources of the wrong version of a library, then you might be shown the wrong line when debugging.
It is possible to disable this (eg by passing -g:none
to javac
). Disabling this will make it a lot harder to locate and troubleshoot problems, but disabling it will make the resulting .class
smaller.
Upvotes: 4