JDK 16 RFR of JDK-8248983: Add Name.isEmpty
forax at univ-mlv.fr
forax at univ-mlv.fr
Thu Jul 9 19:30:37 UTC 2020
----- Mail original -----
> De: "joe darcy" <joe.darcy at oracle.com>
> À: "jonathan gibbons" <jonathan.gibbons at oracle.com>, "Remi Forax" <forax at univ-mlv.fr>
> Cc: "compiler-dev" <compiler-dev at openjdk.java.net>
> Envoyé: Jeudi 9 Juillet 2020 21:25:44
> Objet: Re: JDK 16 RFR of JDK-8248983: Add Name.isEmpty
> On 7/8/2020 5:05 PM, Jonathan Gibbons wrote:
>>
>> On 7/8/20 3:31 PM, forax at univ-mlv.fr wrote:
>>> ----- Mail original -----
>>>>
> [snip]
>
>
>>> I can buy that the concept of empty name is important, following what
>>> you are saying, length() should be re-abstracted for the exact same
>>> reason.
>>> I think i prefer to follow the current implementation of Name that
>>> explain the concept of empty name in the top level javadoc of Name,
>>> and fix the sentence "An empty Name has a length of zero." to mention
>>> isEmpty.
>>
>> The concept of 'empty name' could be explained in the class comment
>> for Name, as Rémi suggests, and enclosed or prefixed by some HTML that
>> defines an 'id' such as "empty-name" that can be referenced from other
>> locations, without having to introduce a new method for the concept.
>> (But, for me, I'm OK either way.)
>>
>
> Following the approach suggested by Jon, here is a version that defines
> and HTML anchor and does *not* introduce a method override:
>
> http://cr.openjdk.java.net/~darcy/8248983.1/
>
> Patch below.
>
> I think this is an improvement over the current API and a bit simpler.
> If others agree, I'll go forward with this change and withdraw the CSR.
Looks good to me :)
>
> Thanks for the reviews,
>
> -Joe
regards,
Rémi
>
> ---
> old/src/java.compiler/share/classes/javax/lang/model/element/Element.java
> 2020-07-09 10:40:04.677417445 -0700
> +++
> new/src/java.compiler/share/classes/javax/lang/model/element/Element.java
> 2020-07-09 10:40:04.289417445 -0700
> @@ -137,7 +137,7 @@
> *
> * If this element represents an unnamed {@linkplain
> * PackageElement#getSimpleName package} or unnamed {@linkplain
> - * ModuleElement#getSimpleName module}, an empty name is returned.
> + * ModuleElement#getSimpleName module}, an <a
> href=Name.html#empty_name>empty name</a> is returned.
> *
> * If it represents a {@linkplain ExecutableElement#getSimpleName
> * constructor}, the name "{@code <init>}" is returned. If it
> @@ -146,7 +146,7 @@
> *
> * If it represents an {@linkplain TypeElement#getSimpleName
> * anonymous class} or {@linkplain ExecutableElement#getSimpleName
> - * instance initializer}, an empty name is returned.
> + * instance initializer}, an <a href=Name.html#empty_name>empty
> name</a> is returned.
> *
> * @return the simple name of this element
> * @see PackageElement#getSimpleName
> ---
> old/src/java.compiler/share/classes/javax/lang/model/element/ExecutableElement.java
> 2020-07-09 10:40:05.517417445 -0700
> +++
> new/src/java.compiler/share/classes/javax/lang/model/element/ExecutableElement.java
> 2020-07-09 10:40:05.089417445 -0700
> @@ -146,7 +146,7 @@
> * initializer. For a constructor, the name {@code "<init>"} is
> * returned, for a static initializer, the name {@code "<clinit>"}
> * is returned, and for an anonymous class or instance
> - * initializer, an empty name is returned.
> + * initializer, an <a href=Name.html#empty_name>empty name</a> is
> returned.
> *
> * @return the simple name of a constructor, method, or
> * initializer
> ---
> old/src/java.compiler/share/classes/javax/lang/model/element/ModuleElement.java
> 2020-07-09 10:40:06.349417445 -0700
> +++
> new/src/java.compiler/share/classes/javax/lang/model/element/ModuleElement.java
> 2020-07-09 10:40:05.893417445 -0700
> @@ -51,7 +51,7 @@
>
> /**
> * Returns the fully qualified name of this module. For an
> - * {@linkplain #isUnnamed() unnamed module}, an empty name is returned.
> + * {@linkplain #isUnnamed() unnamed module}, an <a
> href=Name.html#empty_name>empty name</a> is returned.
> *
> * @apiNote If the module name consists of one identifier, then
> * this method returns that identifier, which is deemed to be
> @@ -69,7 +69,7 @@
>
> /**
> * Returns the simple name of this module. For an {@linkplain
> - * #isUnnamed() unnamed module}, an empty name is returned.
> + * #isUnnamed() unnamed module}, an <a
> href=Name.html#empty_name>empty name</a> is returned.
> *
> * @apiNote If the module name consists of one identifier, then
> * this method returns that identifier. If the module name
> ---
> old/src/java.compiler/share/classes/javax/lang/model/element/Name.java
> 2020-07-09 10:40:07.253417445 -0700
> +++
> new/src/java.compiler/share/classes/javax/lang/model/element/Name.java
> 2020-07-09 10:40:06.785417445 -0700
> @@ -33,7 +33,7 @@
> * implementation are usable in collections while {@code Name}s from
> * different implementations may not work properly in collections.
> *
> - * <p>An empty {@code Name} has a length of zero.
> + * <p><a id="empty_name">An {@linkplain CharSequence#isEmpty() empty}
> {@code Name} has a {@linkplain CharSequence#length() length} of zero.</a>
> *
> * <p>In the context of {@linkplain
> * javax.annotation.processing.ProcessingEnvironment annotation
> ---
> old/src/java.compiler/share/classes/javax/lang/model/element/PackageElement.java
> 2020-07-09 10:40:08.017417445 -0700
> +++
> new/src/java.compiler/share/classes/javax/lang/model/element/PackageElement.java
> 2020-07-09 10:40:07.617417445 -0700
> @@ -53,7 +53,7 @@
> /**
> * Returns the fully qualified name of this package.
> * This is also known as the package's <i>canonical</i> name.
> - * For an {@linkplain #isUnnamed() unnamed package}, an empty name
> is returned.
> + * For an {@linkplain #isUnnamed() unnamed package}, an <a
> href=Name.html#empty_name>empty name</a> is returned.
> *
> * @apiNote The fully qualified name of a named package that is
> * not a subpackage of a named package is its simple name. The
> @@ -70,7 +70,7 @@
>
> /**
> * Returns the simple name of this package. For an {@linkplain
> - * #isUnnamed() unnamed package}, an empty name is returned.
> + * #isUnnamed() unnamed package}, an <a
> href=Name.html#empty_name>empty name</a> is returned.
> *
> * @return the simple name of this package or an empty name if
> * this is an unnamed package
> ---
> old/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java
> 2020-07-09 10:40:08.761417445 -0700
> +++
> new/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java
> 2020-07-09 10:40:08.361417445 -0700
> @@ -121,7 +121,7 @@
> * Returns the fully qualified name of this type element.
> * More precisely, it returns the <i>canonical</i> name.
> * For local and anonymous classes, which do not have canonical names,
> - * an empty name is returned.
> + * an <a href=Name.html#empty_name>empty name</a> is returned.
> *
> * <p>The name of a generic type does not include any reference
> * to its formal type parameters.
> @@ -141,7 +141,7 @@
> /**
> * Returns the simple name of this type element.
> *
> - * For an anonymous class, an empty name is returned.
> + * For an anonymous class, an <a href=Name.html#empty_name> empty
> name</a> is returned.
> *
> * @return the simple name of this class or interface,
> * an empty name for an anonymous class
More information about the compiler-dev
mailing list