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

`var` emits deprecation warnings that do not point to the file or position

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 11, 23
    • tools
    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      `var` emits deprecation warnings that do not point to the file or position of the warning. This leaves me completely unable to determine where the deprecation warning is coming from without setting a breakpoint in javac.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. `javac -Xlint:deprecation Test.java`
      2. See results.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      ```
      Test.java:7: warning: [deprecation] Depr in unnamed package has been deprecated
              for (var deprValue : deprecatedList) {
                   ^
      1 warning
      ```
      ACTUAL -
      ```
      warning: [deprecation] Depr in unnamed package has been deprecated
      1 warning
      ```

      ---------- BEGIN SOURCE ----------
      ```
      import java.util.List;

      public class Test {
          {
              @SuppressWarnings("deprecation")
              List<Depr> deprecatedList = List.of();
              for (var deprValue : deprecatedList) {
                  // ...
              }
          }
      }

      @Deprecated
      class Depr {}
      ```
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use a debugger to breakpoint in the logging of the deprecation warning and check what file it's coming from.

      FREQUENCY : always


            nbenalla Nizar Benalla
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: