简体   繁体   中英

Where do the line numbers point to in Java stacktraces printed by exceptions thrown by code from jars that have no source code jar attached

当在未附加源jar的jar中编译的代码引发异常时,stacktrace中的行号是否引用已编译类中字节码语句的行号?包含源代码的类中的数字?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM