javaeclipsejava-8sonarlintsonarlint-eclipse

Eclipse warning "Replace the type specification in this constructor call with the diamond operator ('<>')" in a Java project


What does Eclipse mean when it asks to Replace the type specification in this constructor call with the diamond operator ('<>'), since the said operator is already there?

Then I put the cursor on what is underlined in blue, and press F2 to learn more, and I get this message (Replace the type specification in this constructor call with the diamond operator ('<>')):

An Eclipse warning saying "Replace the type specification in this constructor call with the diamond operator ('<>')"

And if I delete Object from within <>, Eclipse still is not happy:

An Eclipse warning saying "Replace the type specification in this constructor call with the diamond operator ('<>')"

EDIT

We made sure that

The blue warning still won't go away.


Solution

  • This seems to be a bug in the SonarLint's diamond operator checker, not of Eclipse JDT: see the source code of SonarLint that contains the message.

    See also: SonarJava Rule 2293: The diamond operator ("<>") should be used

    Solution:

    Disable the SonarJava rule 2293 and use the Eclipse warning Generic types > Redundant type argument (1.7 or higher) instead.