diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java index 72662d903af..2158b241c94 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java @@ -521,6 +521,7 @@ public class Annotate { left.name, List.nil(), null); left.sym = method; left.type = method.type; + chk.checkDeprecated(left, env.info.scope.owner, method); if (method.owner != thisAnnotationType.tsym && !badAnnotation) log.error(left.pos(), Errors.NoAnnotationMember(left.name, thisAnnotationType)); Type resultType = method.type.getReturnType(); diff --git a/test/langtools/tools/javac/annotations/DeprecationWarningTest.java b/test/langtools/tools/javac/annotations/DeprecationWarningTest.java new file mode 100644 index 00000000000..5d9e2f2d00c --- /dev/null +++ b/test/langtools/tools/javac/annotations/DeprecationWarningTest.java @@ -0,0 +1,15 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8293519 + * @summary deprecation warnings should be emitted for uses of annotation methods inside other annotations + * @compile/fail/ref=DeprecationWarningTest.out -deprecation -Werror -XDrawDiagnostics DeprecationWarningTest.java + */ + +// both classes can't be inside the same outermost class or the compiler wont emit the warning as `9.6.4.6 @Deprecated` mandates +@interface Anno { + @Deprecated + boolean b() default false; +} + +@Anno(b = true) +class Foo {} diff --git a/test/langtools/tools/javac/annotations/DeprecationWarningTest.out b/test/langtools/tools/javac/annotations/DeprecationWarningTest.out new file mode 100644 index 00000000000..9a6fac53d9b --- /dev/null +++ b/test/langtools/tools/javac/annotations/DeprecationWarningTest.out @@ -0,0 +1,4 @@ +DeprecationWarningTest.java:14:7: compiler.warn.has.been.deprecated: b(), Anno +- compiler.err.warnings.and.werror +1 error +1 warning