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

The diamond finder does not find diamond candidates in field initializers

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 17
    • 17
    • tools
    • None
    • b21

      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

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

              Created:
              Updated:
              Resolved: