quarkusio/quarkus · error · IllegalArgumentException
Unknown annotation attribute value:
Error message
Unknown annotation attribute value:
What it means
Annotations.jandexAnnotationValue() converts a runtime annotation member value into a Jandex AnnotationValue. It handles primitives, String, Class, enum, nested annotations and arrays; any other Java type (arbitrary object) is rejected with IllegalArgumentException. Jandex annotation values must map to one of the metaspace-supported value kinds.
Source
Thrown at independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Annotations.java:313
return org.jboss.jandex.AnnotationValue.createEnumValue(name,
DotName.createSimple(((Enum<?>) value).getDeclaringClass().getName()), ((Enum<?>) value).name());
} else if (value instanceof Class) {
return org.jboss.jandex.AnnotationValue.createClassValue(name, Types.jandexType((Class<?>) value));
} else if (value.getClass().isAnnotation()) {
Class<? extends Annotation> annotationType = annotationType((Annotation) value);
@SuppressWarnings("unchecked")
org.jboss.jandex.AnnotationValue[] jandexAnnotationValues = jandexAnnotationValues(
(Class<Annotation>) annotationType, (Annotation) value);
org.jboss.jandex.AnnotationInstance jandexAnnotation = org.jboss.jandex.AnnotationInstance.create(
DotName.createSimple(annotationType.getName()), null, jandexAnnotationValues);
return org.jboss.jandex.AnnotationValue.createNestedAnnotationValue(name, jandexAnnotation);
} else if (value.getClass().isArray()) {
org.jboss.jandex.AnnotationValue[] jandexAnnotationValues = Arrays.stream(boxArray(value))
.map(it -> jandexAnnotationValue(name, it))
.toArray(org.jboss.jandex.AnnotationValue[]::new);
return org.jboss.jandex.AnnotationValue.createArrayValue(name, jandexAnnotationValues);
} else {
throw new IllegalArgumentException("Unknown annotation attribute value: " + value);
}
}
private static Object[] boxArray(Object value) {
if (value instanceof boolean[]) {
boolean[] primitiveArray = (boolean[]) value;
Object[] boxedArray = new Boolean[primitiveArray.length];
for (int i = 0; i < primitiveArray.length; i++) {
boxedArray[i] = primitiveArray[i];
}
return boxedArray;
} else if (value instanceof byte[]) {
byte[] primitiveArray = (byte[]) value;
Object[] boxedArray = new Byte[primitiveArray.length];
for (int i = 0; i < primitiveArray.length; i++) {
boxedArray[i] = primitiveArray[i];
}
return boxedArray;View on GitHub (pinned to e1c734241f)
Solutions
- Convert the value to a supported type: primitive, String, Class, enum constant, nested annotation, or flat array of these
- For arrays, pass a proper Java array (not a List) of a supported component type
- If building AnnotationInstance directly, use org.jboss.jandex.AnnotationValue.create* methods with matching kinds
- Check the source annotation definition for a member typed outside CDI-allowed types
Example fix
// before
values.put("tags", List.of("a","b")); // List unsupported
// after
values.put("tags", new String[]{"a","b"}); Defensive patterns
Strategy: validation
Validate before calling
static void checkValue(Object v) {
boolean ok = v instanceof String || v instanceof Class || v instanceof Enum
|| v instanceof Annotation || v.getClass().isArray() || v instanceof Number || v instanceof Boolean || v instanceof Character;
if (!ok) throw new IllegalArgumentException("Unsupported: " + v.getClass());
} Type guard
static boolean isJandexSafe(Object v) {
return v == null || v instanceof String || v instanceof Class || v instanceof Enum
|| v instanceof Annotation || v.getClass().isArray();
} Try / catch
try { AnnotationValue av = jandexAnnotationValue(name, val); }
catch (IllegalArgumentException e) { throw new IllegalArgumentException("Member '" + name + "' needs a Jandex-supported value", e); } Prevention
- Never pass Collections/Maps/POJOs as annotation attribute values
- Convert Lists to typed arrays before conversion
- Use AnnotationValue.create* directly when synthesizing instances
When it happens
Trigger: Building a synthetic AnnotationInstance (e.g. via Annotations.create/Jandex value conversion) whose member value is an unsupported object type — e.g. a List, Map, or custom POJO passed as an annotation attribute value.
Common situations: Extensions/tests constructing AnnotationInstance programmatically with wrong member values; reflection-extracted annotation maps containing unexpected types; version drift where a new value kind isn't handled.
Related errors
- Annotation does not have @Retention(RUNTIME):
- Annotation class not available:
- Value is not set for %s.%s(). Most probably an older version
- Class of nested annotation missing
- Array component kind is
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/65ce66bf0ffd7616.
Report an issue: GitHub.