JDK 10 RFR of JDK-8187982: Update SourceVersion to mention restricted keywords

joe darcy joe.darcy at oracle.com
Wed Sep 27 17:07:32 UTC 2017


Hi Maurizio,


On 9/27/2017 1:19 AM, Maurizio Cimadamore wrote:
> Looks good - I agree that treatment of 'var' should be consistent with 
> whatever we do for module-info keywords.
>
> Do you think it could make sense to expose the difference between 
> keywords vs. restricted keywords more 'officially' ? E.g.
>
> public enum NameKind {
>     NAME,
>     KEYWORD
>     RESTRICTED_KEYWORD;
> }
>
> public getNameKind(CharSequence name, SourceVersion version) { ... }
>

And I suppose for completeness, that kind of API would also need a 
non-name item or return null for non-names.

Hmmm. My sense is the additional API surface is not warranted here, but 
if there were examples of annotation processors coding up this kind of 
API for their own use I would reconsider. The intention of the set of 
methods in question was to support some internal queries we wanted to 
write as part of the annotation processing implementation as well as to 
allow processors to have a check of "can I use this name in a program 
for this source version."

(A heavier weight approach would be to define a enum for keywords, 
restricted keywords, and the like, but I think that would be overkill.)

Thanks for the review,

-Joe


More information about the compiler-dev mailing list