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

JSR199 Javac sometimes gives vague errors/warnings and doesn't give access to complete information

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8
    • Fix Version/s: tbd_minor
    • Component/s: tools
    • Labels:

      Description

      For some errors and warnings, JSR199 Javac gives a vague diagnostic code for the problem, and hides the more detailed information about the diagnostic.
      For instance, for a field declaration such as: List<String> list = new ArrayList();, Javac, when using -Xlint:unchecked, gives a warning with code: compiler.warn.prob.found.req. This is a vague, meaningless warning code and not useful for tools using JSR199 Javac who are trying to act upon diagnostics.

      When you look in the diagnostic Object itself, you'll see it has a 'lintCategory' of 'Unchecked' and it has an 'arg' with another Diagnostic that has the code 'compiler.misc.unchecked.assign' which is the code the warning should actually have. Note that both 'lintCategory' and the 'args' are not accessible through JSR199.

      Some possible solutions to make sure tools using JSR199 Javac can understand diagnostics better:
      1) Make sure the diagnostic code uniquely identifies the problem. Use the code of the Diagnostic in the args, if it's there, which is usually more informative, OR make both codes available.
      2) Give access to lintCategory if it's a warning
      3) Give access to Diagnostics in the 'args' if they are there.

      You can use the attached source to display the warning code.

        Attachments

          Activity

            People

            • Assignee:
              jjg Jonathan Gibbons
              Reporter:
              kbronkho Keimpe Bronkhorst
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: