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

  1. Switch the consuming build step to call getAnnotationTransformation() and use the AnnotationTransformation API
  2. If you truly need an AnnotationsTransformer, construct the build item with new AnnotationsTransformerBuildItem((AnnotationsTransformer) ...) instead of an AnnotationTransformation lambda
  3. 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

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


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/1361583940894c7c. Report an issue: GitHub.