Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8020204

Provide column number debug info in addition to line number

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 7
    • Fix Version/s: tbd_major
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • OS:
      windows_7

      Description

      A DESCRIPTION OF THE REQUEST :
      Currently class file may contain debug information about correspondence between part of the Java virtual machine code array and line number in the original source file (LineNumberTable attribute). This information is used at least by debuggers (for setting breakpoints) and jvm (for filling StackTraceElements with line numbers). However information about line numbers only (i.e. without column numbers) is too coarse.

      JUSTIFICATION :
      In case of stacktraces, the source code is often pointed with ambiguity.

      E.g. when we have NullPointerException in following line

      var.foo().bar();

      it's not clear whether var or var.foo() was null.

      Also when we have stacktrace like this

      ...
      at com.some.MyClass.foo(MyClass.java:10)
      at com.some.MyClass.doo(MyClass.java:50)
      ...

      and source file has following line 50

      50: bar(foo(), foo());

      it's not clear whether exception occurred during the first or the second invocation.

      In case of debugger, it's not possible to set breakpoint to particular place within line.

      E.g. when we have following line

      for (int i = 0; i < 100; ++i)

      it's impossible to place breakpoint only to place when variable i is incremented or only to place when i is initialized.



      CUSTOMER SUBMITTED WORKAROUND :
      Some compilers (e.g. eclipse javac) are able generate several line number entries per statement when statement spans several lines. I.e. instead of
         foo(bar(), bar());
      we can stretch it like this:
         foo(
            bar(),
            bar());
      However this does not help with Oracle javac. So the only way to avoid ambiguity is to write like this:
         Bar bar1 = bar();
         Bar bar2 = bar();
         foo(bar1, bar2);
      I.e. use FORTRAN-like style: lot's of temporary variables, use short statements, avoid fluent interfaces and any non-trivial expressions in general.

        Attachments

          Activity

            People

            • Assignee:
              vromero Vicente Arturo Romero Zaldivar
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: