You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2020/09/15 06:04:00 UTC

[jira] [Commented] (GROOVY-9717) 3.0 stubs include packages annotations on classes other than package-info.groovy

    [ https://issues.apache.org/jira/browse/GROOVY-9717?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17195892#comment-17195892 ] 

Paul King commented on GROOVY-9717:
-----------------------------------

The joint compiler now does the right thing wrt annotations only appearing in _package-info.groovy_. Groovy allows annotations to appear on package nodes in more places, e.g. {{@Grab}} (which has SOURCE retention) can appear on a package declaration. I didn't try to expand on what might happen if the retention wasn't SOURCE as part of this issue.

> 3.0 stubs include packages annotations on classes other than package-info.groovy
> --------------------------------------------------------------------------------
>
>                 Key: GROOVY-9717
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9717
>             Project: Groovy
>          Issue Type: Bug
>          Components: Stub generator / Joint compiler
>            Reporter: Keegan Witt
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 4.0.0-alpha-1, 3.0.6
>
>
> {code:java}
> @CustomAnnotation
> package com.foo
> class Foo {}
> @interface CustomAnnotation {}
> {code}
> Generates a stub that has {{@com.foo.CustomAnnotation package com.foo}} in _Foo.java_, which javac won't compile because it requires package annotations to be in _package-info.java_.  Groovy 2.4 and 2.5 don't include this annotation in the stub.
> Ideally, the annotation would be included if in _package-info.groovy_, and otherwise omitted.  But if we had to, and always omitted it, it at least wouldn't be a regression (assuming this difference wasn't made on purpose).
> Possibly we should also consider having the Groovy compiler not allow annotations on packages if not in package-info.groovy, though this would have to be a Groovy 4 thing, and only if it makes sense.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)