United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6769027 : Source line should be displayed immediately after the first diagnostic line

Details
Type:
Enhancement
Submit Date:
2008-11-07
Status:
Closed
Updated Date:
2012-01-13
Project Name:
JDK
Resolved Date:
2012-01-13
Component:
tools
OS:
generic
Sub-Component:
javac
CPU:
unknown,generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Duplicate:
Relates:
Relates:
Relates:

Sub Tasks

Description
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:

Examples:

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))
	<ERROR LINE HERE>
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       
	<ERROR LINE HERE>
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).

                                    

Comments
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!).
                                     
2008-11-07
SUGGESTED FIX

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



Hardware and Software, Engineered to Work Together