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

Source line should be displayed immediately after the first diagnostic line

XMLWordPrintable

    • b50
    • generic, unknown
    • generic
    • Verified

      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).

            mcimadamore Maurizio Cimadamore
            mcimadamore Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: