On Sat, 31 Oct 2020 19:37:10 GMT, Stuart Marks <sma...@openjdk.org> wrote:

>> I believe this changes is useful and still actual:
>> 1. improve code to make it easier to read.
>> 2. performance should be improved a bit too
>
> 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;
     }

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

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

Reply via email to