diagnostics for non-applicable type annotations

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Thu May 2 17:51:27 UTC 2024


Hi Liam,
thanks for looking into this.

You proposed to generate this message:

> test/langtools/tools/javac/annotations/typeAnnotations/failures/CantAnnotateScoping.java:38: 
> error: type annotations are not admissible at this location: @TA
>     @TA Outer.SInner osi;
>              ^
>   (to annotate a qualified type, write Outer. at TA SInner)
I have few questions:

* can this error only be issues when there is a bad type annotation in a 
qualified type? If not, then the latter part of the message might be 
reaching too far
* in other places we have messages like "XYZ not expected here" - 
perhaps might be useful to provide more consistent diagnostics
* Not sure about seeing @TA in the error message after "locaton: " - in 
the sense that the message seems to suggest that what's coming next 
(after the colon) is a location, not the actual annotation?

Maurizio

On 02/05/2024 18:43, Liam Miller-Cushon wrote:
> Hi,
>
> Does anyone on the compiler team have thoughts on this? I'd welcome 
> any feedback.
>
> On Thu, Feb 15, 2024 at 6:59 AM Werner Dietl <wdietl at gmail.com> wrote:
>
>     Thanks for fixing this issue, Liam!
>
>     The revised diagnostic is much better and including a suggested
>     fix makes it even more useful.
>     Like Chris said, this has been a frequent confusion for people.
>
>     I had a look at the PR in January and it looks good to me.
>     There needs to be some discussion
>     <https://github.com/openjdk/jdk/pull/16592#discussion_r1444978083>
>     about whether to use "admissible" or "applicable", but that's a
>     quick fix.
>
>     I'm not a "R"eviewer, but do hope that we can get this PR merged.
>     Please let me know if there is anything I can do to help.
>
>     Best,
>     cu, WMD.
>
>
>     On Mon, Feb 5, 2024 at 7:09 PM Liam Miller-Cushon
>     <cushon at google.com> wrote:
>
>         Thanks Chris!
>
>         Does anyone else have feedback on the proposal?
>
>         On Tue, Jan 9, 2024 at 8:26 AM Chris Povirk
>         <cpovirk at google.com> wrote:
>
>             Thanks, Liam.
>
>             We've found the current error messages to be a source of
>             confusion: While the average user doesn't use type-use
>             annotations, those users who do use them seem to hit this
>             pretty frequently. We have our own FAQ entry about it in
>             our internal documentation, and I also refer people to the
>             Checker Framework's documentation
>             <https://checkerframework.org/manual/#common-problems-non-typechecking>,
>             which gives advice similar to that implemented by Liam's
>             PR. I would expect for that page and this Stack Overflow
>             answer <https://stackoverflow.com/a/21385939/28465> to get
>             more traffic as type-use annotations grow in popularity,
>             as we're aiming for them to do as part of our work on
>             JSpecify nullness. The error-message changes could save
>             users a trip to those docs.
>
>
>
>     -- 
>     https://ece.uwaterloo.ca/~wdietl/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20240502/b9889d0b/attachment-0001.htm>


More information about the compiler-dev mailing list