JDK 16 RFR of JDK-8248983: Add Name.isEmpty
Joe Darcy
joe.darcy at oracle.com
Wed Jul 8 16:23:21 UTC 2020
Hi Remi,
The value of the method is to provide a reference point within the
javax.lang.model API for the "empty name" concept. The goal for the code
in the body of Name.isEmpty is to have as little as possible, preferably
just delegating to CharSequence.isEmpty. I'd prefer to have the empty
name links point to the method Name.isEmpty rather than
CharSequence.isEmpty, hence defining a minimal Name.isEmpty method
within the API.
HTH,
-Joe
On 7/8/2020 5:15 AM, Remi Forax wrote:
> 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