quarkusio/quarkus · error · UnsupportedOperationException
AnnotationTransformation is not an AnnotationsTransformer: $
Error message
AnnotationTransformation is not an AnnotationsTransformer: ${transformer} What it means
AnnotationsTransformerBuildItem historically wrapped an AnnotationsTransformer, but was generalized to hold an AnnotationTransformation (a newer, cheaper API). This deprecated getter throws UnsupportedOperationException when the wrapped object is only an AnnotationTransformation and cannot be cast to AnnotationsTransformer.
Source
Thrown at extensions/resteasy-reactive/rest/spi-deployment/src/main/java/io/quarkus/resteasy/reactive/server/spi/AnnotationsTransformerBuildItem.java:46
*/
@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
- Switch the consuming build step to call getAnnotationTransformation() and use the AnnotationTransformation API
- If you truly need an AnnotationsTransformer, construct the build item with new AnnotationsTransformerBuildItem((AnnotationsTransformer) ...) instead of an AnnotationTransformation lambda
- Update any framework/util code that calls the deprecated getter — it is scheduled for removal
Example fix
// before AnnotationsTransformer t = annotationsTransformerBuildItem.getAnnotationsTransformer(); // throws // after AnnotationTransformation t = annotationsTransformerBuildItem.getAnnotationTransformation();
Defensive patterns
Strategy: type-guard
Validate before calling
Object t = buildItem.getTransformer();
if (!(t instanceof AnnotationsTransformer) && !(t instanceof AnnotationTransformation)) {
throw new IllegalArgumentException("Unsupported transformer type: " + t);
} Type guard
boolean isLegacyTransformer(AnnotationsTransformerBuildItem bi) {
return bi.getAnnotationTransformation() instanceof AnnotationsTransformer;
} Try / catch
try {
AnnotationsTransformer t = item.getAnnotationsTransformer();
} catch (UnsupportedOperationException e) {
AnnotationTransformation t2 = item.getAnnotationTransformation(); // migrate path
} Prevention
- Always use getAnnotationTransformation() — the legacy getter is @Deprecated(forRemoval=true)
- Migrate custom transformers to the AnnotationTransformation API
- Wrap access in an instanceof check on the stored transformer before casting
- Pin consumers and producers of this build item to the same Quarkus version
When it happens
Trigger: Calling (deprecated) AnnotationsTransformerBuildItem.getAnnotationsTransformer() on a build item constructed via new AnnotationsTransformerBuildItem(AnnotationTransformation) rather than with an actual AnnotationsTransformer instance.
Common situations: Extension code updated to the new AnnotationTransformation API but still consumed by older helper code calling the legacy getter; copy-pasted build-step code from older Quarkus versions;@Deprecated(forRemoval=true) migration in progress.
Related errors
- AnnotationTransformation is not an AnnotationsTransformer: <
- filter(OidcRequestContext requestContext) method is not impl
- filter(OidcResponseContext responseContext) method is not im
- Update types are only supported in MongoDB contexts
- Providing multiple BuiltInReaderOverrideBuildItem for the sa
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/1361583940894c7c.
Report an issue: GitHub.