diagnostics for non-applicable type annotations
Liam Miller-Cushon
cushon at google.com
Fri Jan 5 20:56:51 UTC 2024
Hello,
JDK-8043226 is a long-standing bug about the diagnostics for non-applicable
type annotations. This is an example of a current diagnostic:
test/langtools/tools/javac/annotations/typeAnnotations/failures/CantAnnotateScoping.java:38:
error: scoping construct cannot be annotated with type-use annotation: @TA
@TA Outer.SInner osi;
^
Users troubleshooting these diagnostics sometimes find them hard to
resolve, because it isn't intuitive which location is an
admissible location for the annotation. Additionally, the 'scoping
construct' language was used in JSR-308 discussions, but didn't end up in
the final version of the specification.
I think it would be helpful to users for the diagnostic to mention where a
type annotation would be admissible, for example something like:
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 a PR to implement the revised diagnostic here:
https://github.com/openjdk/jdk/pull/16592
Do you think the revised diagnostics are an improvement? Are there any
suggestions for language that would be better? Any feedback on the idea is
welcome.
Thanks,
Liam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20240105/13a8f540/attachment.htm>
More information about the compiler-dev
mailing list