java-topology/test/langtools/tools/javac/warnings/DepAnn.java
russell@unturf.com 0a580b313d undefect. CWE-407 — 63 sites patched across 27 ecosystems
Authors: russell@unturf.com · brackishbert@gmail.com · foxhop.net · TimeHexOn.com

Patches, unit tests, benchmarks, whitepaper, and outreach briefs.
Public domain — no copyright claimed. Use freely.
2026-03-26 17:11:57 -04:00

61 lines
1.1 KiB
Java

/*
* @test /nodynamiccopyright/
* @bug 4986256
* @compile/ref=DepAnn.out -XDrawDiagnostics -Xlint:all,-dangling-doc-comments DepAnn.java
*/
// control: this class should generate warnings
/** @deprecated */
class DepAnn
{
/** @deprecated */
void m1(int i) {
}
}
// tests: the warnings that would otherwise be generated should all be suppressed
@SuppressWarnings("dep-ann")
/** @deprecated */
class DepAnn1
{
/** @deprecated */
void m1(int i) {
/** @deprecated */
int x = 3;
}
}
class DepAnn2
{
@SuppressWarnings("dep-ann")
/** @deprecated */
class Bar {
/** @deprecated */
void m1(int i) {
}
}
@SuppressWarnings("dep-ann")
/** @deprecated */
void m2(int i) {
}
@SuppressWarnings("dep-ann")
static int x = new DepAnn2() {
/** @deprecated */
int m1(int i) {
return 0;
}
}.m1(0);
}
// this class should produce warnings because @SuppressWarnings should not be inherited
/** @deprecated */
class DepAnn3 extends DepAnn1
{
/** @deprecated */
void m1(int i) {
}
}