quarkusio/quarkus · error · UnsupportedOperationException
AnnotationTransformation is not an AnnotationsTransformer: <
Error message
AnnotationTransformation is not an AnnotationsTransformer: <transformer>
What it means
AnnotationsTransformerBuildItem wraps either a legacy AnnotationsTransformer or the newer AnnotationTransformation API. This deprecated accessor throws UnsupportedOperationException when the wrapped object is an AnnotationTransformation (lambda-style) rather than an instance of the old AnnotationsTransformer interface, because it cannot be downcast.
Source
Thrown at extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/AnnotationsTransformerBuildItem.java:45
*/
@Deprecated(forRemoval = true)
public AnnotationsTransformerBuildItem(AnnotationsTransformer transformer) {
this.transformer = transformer;
}
public AnnotationsTransformerBuildItem(AnnotationTransformation transformation) {
this.transformer = transformation;
}
/**
* @deprecated use {@link #getAnnotationTransformation()}
*/
@Deprecated(forRemoval = true)
public AnnotationsTransformer getAnnotationsTransformer() {
if (transformer instanceof AnnotationsTransformer) {
return (AnnotationsTransformer) transformer;
}
throw new UnsupportedOperationException("AnnotationTransformation is not an AnnotationsTransformer: " + transformer);
}
public AnnotationTransformation getAnnotationTransformation() {
return transformer;
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Use getAnnotationTransformation() instead of the deprecated getAnnotationsTransformer()
- If you need an AnnotationsTransformer, construct the build item with an AnnotationsTransformer instance (transformation(combine(AnnotationsTransformer)) style)
- Check `transformer instanceof AnnotationsTransformer` before calling the getter
Example fix
// before AnnotationsTransformer t = item.getAnnotationsTransformer(); // after AnnotationTransformation t = item.getAnnotationTransformation();
Defensive patterns
Strategy: type-guard
Validate before calling
if (item.getAnnotationTransformation() instanceof AnnotationsTransformer at) { /* legacy path */ } Type guard
boolean isLegacyTransformer(AnnotationsTransformerBuildItem item) {
return item.getAnnotationTransformation() instanceof AnnotationsTransformer;
} Prevention
- Prefer getAnnotationTransformation() in all new code
- Treat getAnnotationsTransformer() as removed despite deprecation
- Isolate transformer-consumption code in one helper
When it happens
Trigger: Calling getAnnotationsTransformer() on a build item constructed with an AnnotationTransformation (e.g. via AnnotationsTransformerBuildItem.builder()...transformation(...)), i.e. anything not created with an AnnotationsTransformer instance.
Common situations: Old code or third-party extensions migrated to the new AnnotationTransformation API still consuming the item through the deprecated getter; build steps written before the API split being paired with transformers written after it.
Related errors
- Invalid configuration value set for 'quarkus.arc.remove-unus
- Different default scopes defined for additional bean class:
- Unexpected value: <arcConfig.optimizeContexts()>
- A matching predicate must be set!
- 'target' can only be a class, a field or a method: <target>
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/70f97278f99340f6.
Report an issue: GitHub.