eclipse-jdt/eclipse.jdt.core

RFE: issue (optional) warning when '==' is used on wrapper types

Open

#2.176 geöffnet am 18. März 2024

Auf GitHub ansehen
 (5 Kommentare) (2 Reaktionen) (0 zugewiesene Personen)Java (183 Forks)auto 404
enhancementhelp wanted

Repository-Metriken

Stars
 (233 Stars)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

I would like that Eclipse (similar to IDEA) would issue an optional warning when one uses the following construct:

Long x1 = 12345L;
Long x2 = 67890L;
if(x1 == x2)
    System.out.println("Equal");
else
    System.out.println("Not equal");

Because (as apparently we don't all know) Long is a wrapper class and using == only works for Long values between -127 and 127 due to caching (similarly for the other wrapper types).

This would at least uncover one such instance in our code base, of which I suspect to find a greater number alas.

Contributor Guide