quarkusio/quarkus · error · UnsupportedOperationException

AnnotationTransformation is not an AnnotationsTransformer: "

Error message

AnnotationTransformation is not an AnnotationsTransformer: " + transformer

What it means

RestClientAnnotationsTransformerBuildItem wraps an AnnotationTransformation; this getter casts it to the legacy AnnotationsTransformer interface. If the wrapped object is only an AnnotationTransformation (the newer API), it cannot be viewed as an AnnotationsTransformer, so an UnsupportedOperationException is thrown. This exists because the deprecated accessor assumes an old-style transformer was supplied.

Source

Thrown at extensions/resteasy-reactive/rest-client/spi-deployment/src/main/java/io/quarkus/rest/client/reactive/spi/RestClientAnnotationsTransformerBuildItem.java:46

     */
    @Deprecated(forRemoval = true)
    public RestClientAnnotationsTransformerBuildItem(AnnotationsTransformer transformer) {
        this.transformer = transformer;
    }

    public RestClientAnnotationsTransformerBuildItem(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. Use getAnnotationTransformation() instead of the deprecated getAnnotationsTransformer()
  2. If you need an AnnotationsTransformer, construct the build item with an AnnotationsTransformer implementation instead of an AnnotationTransformation lambda
  3. Remove use of the deprecated accessor; it is marked @Deprecated(forRemoval = true) and will be deleted

Example fix

// before
AnnotationsTransformer t = item.getAnnotationsTransformer();
// after
AnnotationTransformation t = item.getAnnotationTransformation();
Defensive patterns

Strategy: validation

Validate before calling

if (item.getAnnotationTransformation() == null && !(item instanceof RestClientAnnotationsTransformerBuildItem it && it.getAnnotationTransformation() instanceof AnnotationsTransformer)) { throw new IllegalStateException("Build item does not wrap an AnnotationsTransformer"); }

Type guard

boolean isLegacyTransformer(RestClientAnnotationsTransformerBuildItem item) { return item.getAnnotationTransformation() instanceof AnnotationsTransformer; }

Try / catch

try { t = item.getAnnotationsTransformer(); } catch (UnsupportedOperationException e) { t = null; /* use getAnnotationTransformation() */ }

Prevention

When it happens

Trigger: Calling getAnnotationsTransformer() on a RestClientAnnotationsTransformerBuildItem that was constructed with an AnnotationTransformation (lambda or functional style) rather than an AnnotationsTransformer implementation, typically from another build step or custom extension code.

Common situations: Extension authors migrating between the deprecated AnnotationsTransformer API and the newer AnnotationTransformation API; calling the old getter out of habit after switching the constructor argument to a lambda.

Related errors


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