Question

I have a exe in C++, through it I am using a jar file through JNI layer utility. both C++ and Java have it's own separate logging functionality, I am facing a unique problem, while logging for Java module, StackTraceElement gives -1 value for getLineNumber() call, while Classname, methodname are proper one, even I tried to print whole stack for each StackTraceElement, getting getLineNumber value as -1. cn't figure out the root cause. any input will be appreciable.

Was it helpful?

Solution

Possibly the code was compiled without debugging information included. From the javac man page:

-g
Generate all debugging information, including local variables. By default, only line number and source file information is generated.

-g:none
Do not generate any debugging information.

-g:{keyword list}
Generate only some kinds of debugging information, specified by a comma separated list of keywords. Valid keywords are:
source Source file debugging information
lines Line number debugging information
vars Local variable debugging information

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top