JDK 10 RFR of 8191234: TypeKindVisitor needs to handle modules,
Jonathan Gibbons
jonathan.gibbons at oracle.com
Mon Nov 27 19:27:05 UTC 2017
Webrev looks OK.
-- Jon
On 11/22/2017 01:56 PM, joe darcy wrote:
> Hi Jon,
>
>
> On 11/22/2017 11:42 AM, Jonathan Gibbons wrote:
>> Question ...
>>
>> In TypeKindVisitor6, visitNoTypeAsModule, you specify that the return
>> value is the result of visitUnknown. That is not true of the
>> override in TypeKindVisitor9. That raises the question: are @param
>> and @return specs conceptually part of the API-spec, or part of the
>> implSpec?
>
> Yes, that is a bit of a detail -- the method in TypeKindVisitor9.java
> does provide an explicit @return tag that doesn't @inheritDoc the spec
> from the @return in TypeKindVisitor6. So the javadoc for the classes
> in the API is correct, but there are implications for subclasses
> outside of the javax.lang.model.util.* API.
>
> With the change as written, a subclass that overrode this visitXasY
> method would need to both provide a doc comment for the method as well
> as for the @return tag.
>
> The javadoc tags here are treated the same way as
> ElementKind{$N}.visitVariableAsResourceVariable.
>
> I don't know if we have a broader convention on this point.
>
> Thanks,
>
> -Joe
>
>>
>> -- Jon
>>
>>
>>
>> On 11/22/2017 10:37 AM, joe darcy wrote:
>>> Webrev now with a regression test:
>>>
>>> http://cr.openjdk.java.net/~darcy/8191234.1/
>>>
>>> Thanks,
>>>
>>> -Joe
>>>
>>> On 11/20/2017 10:34 PM, joe darcy wrote:
>>>> Hello,
>>>>
>>>> Please review the patch below and CSR for
>>>>
>>>> 8191234: TypeKindVisitor needs to handle modules
>>>> CSR: https://bugs.openjdk.java.net/browse/JDK-8191642
>>>>
>>>> The module-related javax.lang.model updates in JDK 9 overlooked
>>>> adding module support to the TypeKind family of visitors.
>>>>
>>>> The treatment of TypeKind.MODULE is analogous to the how support
>>>> for ElementKind.RESOURCE_VARIABLE was added in JDK 7 to the
>>>> ElementKind visitors.
>>>>
>>>> For now treating this fix was noreg-trivial, but I'll concede test
>>>> are appropriate and write a few if reviewers think they are needed.
>>>>
>>>> Thanks,
>>>>
>>>> -Joe
>>>>
>>>> diff -r 5cc5b8270cad
>>>> src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor6.java
>>>> ---
>>>> a/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor6.java
>>>> Mon Nov 20 20:33:51 2017 -0800
>>>> +++
>>>> b/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor6.java
>>>> Mon Nov 20 22:06:30 2017 -0800
>>>> @@ -257,7 +257,7 @@
>>>> *
>>>> * @implSpec This implementation dispatches to the visit
>>>> method for
>>>> * the specific {@linkplain TypeKind kind} of pseudo-type:
>>>> - * {@code VOID}, {@code PACKAGE}, or {@code NONE}.
>>>> + * {@code VOID}, {@code PACKAGE}, {@code MODULE}, or {@code
>>>> NONE}.
>>>> *
>>>> * @param t {@inheritDoc}
>>>> * @param p {@inheritDoc}
>>>> @@ -273,6 +273,9 @@
>>>> case PACKAGE:
>>>> return visitNoTypeAsPackage(t, p);
>>>>
>>>> + case MODULE:
>>>> + return visitNoTypeAsModule(t, p);
>>>> +
>>>> case NONE:
>>>> return visitNoTypeAsNone(t, p);
>>>>
>>>> @@ -308,6 +311,21 @@
>>>> }
>>>>
>>>> /**
>>>> + * Visits a {@link TypeKind#MODULE MODULE} pseudo-type.
>>>> + *
>>>> + * @implSpec This implementation calls {@code visitUnknown}.
>>>> + *
>>>> + * @param t the type to visit
>>>> + * @param p a visitor-specified parameter
>>>> + * @return the result of {@code visitUnknown}
>>>> + *
>>>> + * @since 10
>>>> + */
>>>> + public R visitNoTypeAsModule(NoType t, P p) {
>>>> + return visitUnknown(t, p);
>>>> + }
>>>> +
>>>> + /**
>>>> * Visits a {@link TypeKind#NONE NONE} pseudo-type.
>>>> *
>>>> * @implSpec This implementation calls {@code defaultAction}.
>>>> diff -r 5cc5b8270cad
>>>> src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor9.java
>>>> ---
>>>> a/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor9.java
>>>> Mon Nov 20 20:33:51 2017 -0800
>>>> +++
>>>> b/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor9.java
>>>> Mon Nov 20 22:06:30 2017 -0800
>>>> @@ -93,4 +93,20 @@
>>>> protected TypeKindVisitor9(R defaultValue) {
>>>> super(defaultValue);
>>>> }
>>>> +
>>>> + /**
>>>> + * {@inheritDoc}
>>>> + *
>>>> + * @implSpec This implementation calls {@code defaultAction}.
>>>> + *
>>>> + * @param t {@inheritDoc}
>>>> + * @param p {@inheritDoc}
>>>> + * @return the result of {@code defaultAction}
>>>> + *
>>>> + * @since 10
>>>> + */
>>>> + @Override
>>>> + public R visitNoTypeAsModule(NoType t, P p) {
>>>> + return defaultAction(t, p);
>>>> + }
>>>> }
>>>>
>>>
>>
>
More information about the compiler-dev
mailing list