JDK-6769027 : Source line should be displayed immediately after the first diagnostic line
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic,unknown
  • Submitted: 2008-11-07
  • Updated: 2012-01-13
  • Resolved: 2012-01-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
7 b50Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Recent work on javac diagnostics have underlined the need for better diagnostics; the diagnostics to be improved, esp. those regarding the type-system area of the compiler, have a problem in that they could in principle add too many lines before the erroneous source line is diaplayed; consider the following cases:


1) Type-system diagnostic:

Test.java:3: method test in class Foo<T #0> cannot be applied to given types
   required: T #0
   found: T #1
      where T #0,T #1 are typevariables:
          T #0 extends String
              (declared in class Foo)
          T #1 extends Integer
              (declared in method <T>foo(T))
1 error

2) Method resolution diagnostics

Test.java:6: no suitable method m found for (String,String)
    method: <T>m(T,T) in Test
      (inferred type argument(s) String do not conform to bounds of type variable(s) T)
    method: m(Integer) in Test       
1 error

Despite being an effective way for separating different diagnostics, having source line printed only at the end of the diagnostic output makes the whole diagnostic (i) less readable - because people have to parser the diagnostic contents in order to find the actual erroneous line and (ii) less scalable - because we would like to be able to give the users the flexibility to turn on/off diagnostic features (e.g. where clauses/detailed diagnostics).

SUGGESTED FIX A webrev of this fix is available at the following URL: http://hg.openjdk.java.net/jdk7/tl/langtools/rev/6ada6122dd4f

EVALUATION Will do. Many have suggested that the following template should be adopted: <FIRST LINE> <ERROR LINE> <CARET> <DIAGNOSTIC DETAILS> <SEPARATOR> Note that a separator (e.g. newline) is required in order to provide better visual feedback to the user (since the caret is not the last thing of a diagnostic anymore!).