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

DiagnosticListener should receive MANDATORY_WARNING in standard compiler mode

    XMLWordPrintable

Details

    • b112
    • generic
    • generic

    Description

      javax.tools.DiagnosticListener doesn't receive MANDATORY_WARNING kind diagnostics required by the JLS 3 in the default compiler mode.

      You can find attached java sources that help to reporoduce the problem. They are based on the API spec and the JLS 3 sample assertions below:
      ===JSR 199: javax.tools.Diagnostic.Kind===
      MANDATORY_WARNING
      public static final Diagnostic.Kind MANDATORY_WARNING
          Problem similar to a warning, but is mandated by the tool's specification. For example, the
      Java™ Language Specification, 3rd Ed. mandates warnings on certain unchecked operations and the use
      of deprecated methods.
      ==========================================

      ===JLS sample=======
      1) §4.8 ...assignment from Vector to Vector<String> is unsafe (since the raw vector might have had a
      different element type), but is still permitted using unchecked conversion (§5.1.9) in order to
      enable interfacing with legacy code. In this case, a compiler will issue an unchecked warning.

         §5.1.9 ...an unchecked conversion from the raw type (§4.8) G to any parameterized type of the
      form G<T1 ... Tn>. Use of an unchecked conversion generates a mandatory compile-time warning.

      2) §9.1.6 ...program element annotated @Deprecated is one that programmers are discouraged from
      using, typically because it is dangerous, or because a better alternative exists. A Java compiler
      must produce a warning when a deprecated type, method, field, or constructor is used
      ===JLS=======

      JSR199Cmd compiles A.java file via JSR 199. If you run it you will see the following results.

      ==== Diagnostic ====
      Note: src/A.java uses or overrides a deprecated API.
      -1 Note: src/A.java uses or overrides a deprecated API.
      null NOTE
      ==== Diagnostic ====
      Note: Recompile with -Xlint:deprecation for details.
      -1 Note: Recompile with -Xlint:deprecation for details.
      null NOTE
      ==== Diagnostic ====
      Note: src/A.java uses unchecked or unsafe operations.
      -1 Note: src/A.java uses unchecked or unsafe operations.
      null NOTE
      ==== Diagnostic ====
      Note: Recompile with -Xlint:unchecked for details.
      -1 Note: Recompile with -Xlint:unchecked for details.
      null NOTE

      MANDATORY_WARNINGs could be switched on by passing non-standard compiler options: -Xlint:unchecked -Xlint:deprecation.

      Attachments

        Issue Links

          Activity

            People

              jjg Jonathan Gibbons
              agavrilosunw Alexey Gavrilov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: