JDK 16 RFR of JDK-8248983: Add Name.isEmpty

Remi Forax forax at univ-mlv.fr
Wed Jul 8 12:15:52 UTC 2020


HI Joe,
I don't understand the value that this method provides,
because either the JDK 15 is the bootstrap JDK and in this case, this code is useless because CharSequence.isEmpty() already provides the right behavior,
or you don't and it will not compile.

So either you write it to delegate to length() so you are not dependent of JDK 15 being the bootstrap JDK or you do nothing and you will get isEmpty() for free when the JDK 15 will be the bootstrap JDK.

public interface Name extends CharSequence {
     /**
+     * Returns {@code true} if this is an empty name with a length of
+     * zero; returns {@code false} otherwise.
+     * @return {@code true} for an empty name and {@code false} otherwise.
+     *
+     * @since 16
+     */
+    default boolean isEmpty() {
+        return length() == 0;
+    }

regards,
Rémi

----- Mail original -----
> De: "joe darcy" <joe.darcy at oracle.com>
> À: "compiler-dev" <compiler-dev at openjdk.java.net>
> Envoyé: Mercredi 8 Juillet 2020 04:23:32
> Objet: JDK 16 RFR of JDK-8248983: Add Name.isEmpty

> Hello,
> 
> Please review the webev and CSR for
> 
>     JDK-8248983: Add Name.isEmpty
>     CSR: https://bugs.openjdk.java.net/browse/JDK-8249005
>     webrev: http://cr.openjdk.java.net/~darcy/8248983.0/
> 
> In its current form, this fix can only be pushed *after* the minimum
> boot JDK in the JDK 16 build is updated to JDK 15. Otherwise, the
> default method on CharSequence is not necessarily present.
> 
> To be pushed earlier, the default method on Name would need to be
> changed to host an implementation that didn't delegate to
> CharSequence.isEmpty. It would not be difficult to take that route
> instead with a follow-up bug to change the implementation of the default
> method later.
> 
> Thanks,
> 
> -Joe


More information about the compiler-dev mailing list