JDK 14 RFR of JDK-8230337: Clarify intention of Elements.{getPackageOf, getModuleOf}

Joe Darcy joe.darcy at oracle.com
Fri Aug 30 17:59:17 UTC 2019


Now with tests:

     http://cr.openjdk.java.net/~darcy/8230337.2/

Jon, I'll update the CSR to match the spec text you previously approved 
and add you as a reviewer there.

Thanks,

-Joe

On 8/29/2019 9:16 PM, Jonathan Gibbons wrote:
> +1
>
> -- Jon
>
> On 8/29/19 4:45 PM, Joe Darcy wrote:
>> Hi Jon,
>>
>> For getModuleOf, how about:
>>
>>     /**
>>      * Returns the module of an element.  The module of a module is
>>      * itself.
>>      *
>>      * If a package has a module as its {@linkplain
>>      * PackageElement#getEnclosingElement enclosing element}, that
>>      * module is the module of the package. If the enclosing element
>>      * of a package is {@code null}, {@code null} is returned for the
>>      * package's module.
>>      *
>>      * (One situation where a package may have a {@code null} module
>>      * is if the environment does not include modules, such as an
>>      * annotation processing environment configured for a {@linkplain
>>      * 
>> javax.annotation.processing.ProcessingEnvironment#getSourceVersion
>>      * source version} without modules.)
>>      *
>>      * Otherwise, the module of an element is equal to the module
>>      * {@linkplain #getPackageOf(Element) of the package} of the
>>      * element.
>>      *
>>      * @implSpec The default implementation of this method returns
>>      * {@code null}.
>>      *
>>      * @param e the element being examined
>>      * @return the module of an element
>>      * @since 9
>>      * @spec JPMS
>>      */
>>     default ModuleElement getModuleOf(Element e)
>>
>> -Joe
>>
>> On 8/29/2019 2:05 PM, Jonathan Gibbons wrote:
>>> Joe,
>>>
>>> The if-otherwise doesn't work here as you might have intended.
>>>
>>> If the package doesn't have a module for its enclosing element you
>>> fall into infinitely recursive "otherwise".
>>>
>>> -- Jon
>>>
>>> On 8/29/19 11:30 AM, Joe Darcy wrote:
>>>>
>>>> +     * If a package has a module as its {@linkplain
>>>> +     * PackageElement#getEnclosingElement enclosing element}, that
>>>> +     * module is the module of the package. Otherwise, the module of
>>>> +     * an element is equal to the module {@linkplain
>>>> +     * #getPackageOf(Element) of the package} of the element.
>>>> +     * 


More information about the compiler-dev mailing list