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

The diamond finder does not find diamond candidates in field initializers

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 17
    • Fix Version/s: 17
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b21

      Description

      Consider code like:
      ---
      public class Test {
           private List<String> l = new ArrayList<String>();
      }
      ---

      Running javac with -XDfind=diamond will not produce a warning about the diamond candidate, while doing the some on:
      ---
      public class Test {
           List<String> l = new ArrayList<String>();
      }
      ---

      will produce:
      Test.java:4: warning: Redundant type arguments in new expression (use diamond operator instead).
           List<String> l = new ArrayList<String>();
                                         ^
      1 warning

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jlahoda Jan Lahoda
              Reporter:
              jlahoda Jan Lahoda
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: