java-topology/test/langtools/tools/javac/T8182747/BadAnnotationRegressionTest.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

45 lines
928 B
Java

/* @test /nodynamiccopyright/
* @bug 8182747
* @summary javac crashes on bad annotation value
* @compile/fail/ref=BadAnnotationRegressionTest.out -XDrawDiagnostics BadAnnotationRegressionTest.java
*/
class BadAnnotationRegressionTest {
@interface ClassAnno {
Class<?> value();
}
@interface ArrayAnno {
int[] value();
}
@interface PrimitiveAnno {
int value();
}
@interface StringAnno {
String value();
}
enum E {
A,
B,
}
@interface EnumAnno {
E value();
}
static final Class<?> c = Object.class;
static final int i = 0;
static final int[] arr = new int[] { 1, 2, 3 };
static final E a = E.A;
static final String s = "";
@ClassAnno(c) // error
@PrimitiveAnno(i) // ok
@ArrayAnno(arr) // error
@EnumAnno(a) // error
@StringAnno(s) //ok
void testAnno() {}
}