On Mon, 2 Nov 2020 09:15:31 GMT, Chris Hegarty <che...@openjdk.org> wrote:

>> I’ll see if I can get somebody to take a look at this.
>
> This seems like a reasonable change, which improves readability.
> 
> My preference is to wait a little longer (hopefully no more than a couple of 
> weeks), until [JEP 394](https://openjdk.java.net/jeps/394) - "Pattern 
> Matching for instanceof" is finalised, then we can remove the explicit casts 
> in many of these cases. For example:
> 
> --- a/src/java.base/share/classes/java/io/File.java
> +++ b/src/java.base/share/classes/java/io/File.java
> @@ -2191,8 +2191,8 @@ public class File
>       *          {@code false} otherwise
>       */
>      public boolean equals(Object obj) {
> -        if ((obj != null) && (obj instanceof File)) {
> -            return compareTo((File)obj) == 0;
> +        if (obj instanceof File file) {
> +            return compareTo(file) == 0;
>          }
>          return false;
>      }

Related issue - https://bugs.openjdk.java.net/browse/JDK-8257448

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

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

Reply via email to