On Fri, 25 Feb 2022 23:30:35 GMT, Yasser Bazzi <d...@openjdk.java.net> wrote:

>> src/java.base/share/classes/java/util/Random.java line 107:
>> 
>>> 105:                 return rand;
>>> 106: 
>>> 107:             return (Random) new Random.RandomWrapper(random);
>> 
>> Isn't the `(Random)` cast redundant?
>
> Eclipse did not complain about it being redundant, also it does not impact 
> the reading of it and it shows the reader it is a Random instance that is 
> returning

It is unlikely that any IDE or code scanning tool will report _all_ cases of 
incorrect or redundant code. However, in this specific case Eclipse does 
support detecting that (to my knowledge) through its "Clean Up" action (you 
might to explicitly enable though). But you should always verify that the 
actions Eclipse (or any other IDE) performs are correct, because there are some 
reported corner cases where it removes casts which are actually needed.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7001

Reply via email to