Skip to main content

Improved Stack Trace

3 replies [Last post]
Joined: 2004-03-04


I would like to know if there are reasons (beside tool compatibility) to not introduce the column number (or even better the variable name) for NPEs.

A lot of code has lines like:

int i = var1.getMeTheResultsFor(param1, var2.getProperty(x)).getInt();

The stacktrace right now indicates the line number but it does not indicate which of the possible variables in that line are null.

In the above example the culprits could be:

var1, var2 or the result of var1.getMeTheResultsFor() method.


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2008-04-13

Column start/end is an important information missing in the byte code. We heavily really on this information for our tool ( Without column information our software produces reports which are much harder to understand. Besides that from a conceptual point of view it does not make sense to provide line numbers and skip column information at the same time. Just imagine how debuggers and other byte code level tools could improve the user experience with column information.

Is there any progress on this issue ? Any news ?

best regards,


Joined: 2004-09-03

There has been talk of an expanded LineNumberTable attribute in the debugger team, and as I understand it, the javac compiler is fully capable of adding this additional information. Once you have a full bytecode offset -> (line,column) mapping, things start to become possible in terms of identifying specific positions in lines. But as you can imagine, this isn't a small feat. It would need to be done in a way that doesn't bloat the classfiles too much, and a detailed specification of the attribute would need to be written up. Then the proper JVM TI and JDI changes need to be added to support such a thing.

But I don't think the columns are necessary to just dump out the current local variables and their values. A good Java debugger should be able to catch the NPE and then you should be able to print out all the values of the local variables, assuming the class file was compiled with 'javac -g' so that the LocalVariableTable attribute exists in that classfile. You might try using a Java debugger and see if that helps.

Joined: 2003-12-02

Or maybe reduce the number of operations you use on a single line and drill down to the root cause that way.