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

javac fix inconsistent diagnostic messages

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • 8
    • 8
    • tools
    • generic
    • generic

      While fixing 7073631, it was noticed some positions are not being reported
      correctly:

      test/tools/javac/TryWithResources/DuplicateResourceDecl.java:12: warning: [try] auto-closeable resource MyResource has a member method close() that could throw InterruptedException
              try(MyResource c = new MyResource();MyResource c = new MyResource()) {
                             ^
      The diagnostics says MyResource but the caret points to "c".

      Similarly, it is inconsistent whether "auto-closeable resource" names a class
      MyResource or an instance r1.

      test/tools/javac/TryWithResources/DuplicateResourceDecl.java:12: error: c is already defined in main(String[])
              try(MyResource c = new MyResource();MyResource c = new MyResource()) {
                                                             ^
      test/tools/javac/TryWithResources/DuplicateResourceDecl.java:12: warning: [try] auto-closeable resource MyResource has a member method close() that could throw InterruptedException
              try(MyResource c = new MyResource();MyResource c = new MyResource()) {
                                                             ^
      test/tools/javac/TryWithResources/DuplicateResourceDecl.java:17: warning: [try] auto-closeable resource MyResource has a member method close() that could throw InterruptedException
          static class MyResource implements AutoCloseable {
                 ^
      test/tools/javac/TryWithResources/TwrFlow.java:14: error: exception IOException is never thrown in body of corresponding try statement
              } catch (IOException ioe) { // Not reachable
                ^

      >>>>>>>>> message says IOException but caret points to "catch"

            ksrini Kumar Srinivasan
            ksrini Kumar Srinivasan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: