mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-27 10:40:29 +00:00
8368864: Confusing error message (or wrong error) when record component has @deprecated Javadoc tag
Reviewed-by: jlahoda
This commit is contained in:
parent
3b8abd459f
commit
4f83d211d1
@ -5406,6 +5406,12 @@ public class JavacParser implements Parser {
|
||||
|
||||
if (recordComponent) {
|
||||
mods = modifiersOpt();
|
||||
/* it could be that the user added a javadoc with the @deprecated tag, when analyzing this
|
||||
* javadoc, javac will set the DEPRECATED flag. This is correct in most cases but not for
|
||||
* record components and thus should be removed in that case. Any javadoc applied to
|
||||
* record components is ignored
|
||||
*/
|
||||
mods.flags &= ~Flags.DEPRECATED;
|
||||
} else {
|
||||
mods = optFinal(Flags.PARAMETER | (lambdaParameter ? Flags.LAMBDA_PARAMETER : 0));
|
||||
}
|
||||
|
||||
@ -2169,4 +2169,56 @@ class RecordCompilationTests extends CompilationTestCase {
|
||||
"""
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDeprecatedJavadoc() {
|
||||
String[] previousOptions = getCompileOptions();
|
||||
try {
|
||||
setCompileOptions(new String[] {"-Xlint:deprecation"});
|
||||
assertOKWithWarning("compiler.warn.has.been.deprecated",
|
||||
"""
|
||||
record R(
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
int i
|
||||
) {}
|
||||
class Client {
|
||||
R r;
|
||||
int j = r.i();
|
||||
}
|
||||
"""
|
||||
);
|
||||
assertOKWithWarning("compiler.warn.has.been.deprecated",
|
||||
"""
|
||||
record R(
|
||||
@Deprecated
|
||||
int i
|
||||
) {}
|
||||
class Client {
|
||||
R r;
|
||||
int j = r.i();
|
||||
}
|
||||
"""
|
||||
);
|
||||
// javadoc tag only has no effect
|
||||
assertOK(
|
||||
"""
|
||||
record R(
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
int i
|
||||
) {}
|
||||
class Client {
|
||||
R r;
|
||||
int j = r.i();
|
||||
}
|
||||
"""
|
||||
);
|
||||
} finally {
|
||||
setCompileOptions(previousOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user