<div dir="ltr">Hello,<div><br></div><div>JDK-8043226 is a long-standing bug about the diagnostics for non-applicable type annotations. This is an example of a current diagnostic:</div><div><br></div><div><font face="monospace">test/langtools/tools/javac/annotations/typeAnnotations/failures/CantAnnotateScoping.java:38: error: scoping construct cannot be annotated with type-use annotation: @TA<br>    @TA Outer.SInner osi;<br>             ^</font><br></div><div>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.</div><div><br></div><div>I think it would be helpful to users for the diagnostic to mention where a type annotation would be admissible, for example something like:</div><div><br></div><div><font face="monospace">test/langtools/tools/javac/annotations/typeAnnotations/failures/CantAnnotateScoping.java:38: error: type annotations are not admissible at this location: @TA<br>    @TA Outer.SInner osi;<br>             ^<br>  (to annotate a qualified type, write Outer.@TA SInner)</font><br></div><div><br></div><div>I have a PR to implement the revised diagnostic here: <a href="https://github.com/openjdk/jdk/pull/16592" target="_blank">https://github.com/openjdk/jdk/pull/16592</a></div><div><br></div><div>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.</div><div><br></div><div>Thanks,</div><div>Liam</div></div>