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

Jonathan Gibbons jonathan.gibbons at oracle.com
Fri Aug 30 18:07:38 UTC 2019


Style typo, but otherwise OK.

http://cr.openjdk.java.net/~darcy/8230337.2/test/langtools/tools/javac/processing/model/util/elements/TestGetPackageOf.java.sdiff.html

65 for(var testCase : testCases.entrySet()) {

add space between 'for' and '('.

-- Jon

On 8/30/19 10:59 AM, Joe Darcy wrote:
> 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.
>>>>> +     * 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20190830/1f3c22a2/attachment.html>


More information about the compiler-dev mailing list