Skip to content

Commit 6beadbb

Browse files
author
Vicente Romero
committed
8293519: deprecation warnings should be emitted for uses of annotation methods inside other annotations
Reviewed-by: jlahoda
1 parent 4bef233 commit 6beadbb

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ private Pair<MethodSymbol, Attribute> attributeAnnotationNameValuePair(JCExpress
521521
left.name, List.nil(), null);
522522
left.sym = method;
523523
left.type = method.type;
524+
chk.checkDeprecated(left, env.info.scope.owner, method);
524525
if (method.owner != thisAnnotationType.tsym && !badAnnotation)
525526
log.error(left.pos(), Errors.NoAnnotationMember(left.name, thisAnnotationType));
526527
Type resultType = method.type.getReturnType();
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* @test /nodynamiccopyright/
3+
* @bug 8293519
4+
* @summary deprecation warnings should be emitted for uses of annotation methods inside other annotations
5+
* @compile/fail/ref=DeprecationWarningTest.out -deprecation -Werror -XDrawDiagnostics DeprecationWarningTest.java
6+
*/
7+
8+
// both classes can't be inside the same outermost class or the compiler wont emit the warning as `9.6.4.6 @Deprecated` mandates
9+
@interface Anno {
10+
@Deprecated
11+
boolean b() default false;
12+
}
13+
14+
@Anno(b = true)
15+
class Foo {}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
DeprecationWarningTest.java:14:7: compiler.warn.has.been.deprecated: b(), Anno
2+
- compiler.err.warnings.and.werror
3+
1 error
4+
1 warning

0 commit comments

Comments
 (0)