quarkusio/quarkus · error · IllegalArgumentException

Getter '${getterName}' of class '${returnTypeClassInfo}' mus

Error message

Getter '${getterName}' of class '${returnTypeClassInfo}' must be public

What it means

When generating a mapper that reads properties of a multipart OUTPUT form class back from a request, FormDataOutputMapperGenerator calls the bean getter. If a getter exists in the hierarchy but is not public (and field access is not being used), the generated mapper cannot invoke it, so the build fails with this IllegalArgumentException.

Source

Thrown at independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/generation/multipart/FormDataOutputMapperGenerator.java:177

                    AnnotationInstance formParamInstance = field.annotation(REST_FORM_PARAM);
                    if (formParamInstance == null) {
                        formParamInstance = field.annotation(FORM_PARAM);
                    }
                    if (formParamInstance == null) { // fields not annotated with @RestForm or @FormParam are completely ignored
                        continue;
                    }

                    boolean useFieldAccess = false;
                    String getterName = JavaBeanUtil.getGetterName(field.name(), field.type().name());
                    Type fieldType = field.type();
                    DotName fieldDotName = fieldType.name();
                    MethodInfo getter = currentClassInHierarchy.method(getterName);
                    if (getter == null) {
                        // even if the field is private, it will be transformed to be made public
                        useFieldAccess = true;
                    }
                    if (!useFieldAccess && !Modifier.isPublic(getter.flags())) {
                        throw new IllegalArgumentException(
                                "Getter '" + getterName + "' of class '" + returnTypeClassInfo + "' must be public");
                    }

                    String formAttrName = field.name();
                    AnnotationValue formParamValue = formParamInstance.value();
                    if (formParamValue != null) {
                        formAttrName = formParamValue.asString();
                    }

                    // TODO: not sure this is correct, but it seems to be what RESTEasy does and it also makes most sense in the context of a POJO
                    String partType = MediaType.TEXT_PLAIN;
                    AnnotationInstance partTypeInstance = field.annotation(ResteasyReactiveDotNames.PART_TYPE_NAME);
                    if (partTypeInstance != null) {
                        AnnotationValue partTypeValue = partTypeInstance.value();
                        if (partTypeValue != null) {
                            partType = partTypeValue.asString();
                        }
                    }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Make the getter public in the form class.
  2. If the getter is non-public in a superclass, override it publicly in the subclass.
  3. Remove the getter so the generator falls back to field access (fields are made public during transformation).

Example fix

// before
class UploadForm {
    protected String getName() { return name; }
}
// after
class UploadForm {
    public String getName() { return name; }
}
Defensive patterns

Strategy: validation

Validate before calling

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

void validateFormGettersPublic(Class<?> formClass) {
    for (Method m : formClass.getMethods()) {
        if (m.getParameterCount() == 0 && m.getName().startsWith("get")
                && m.getDeclaringClass() == formClass
                && !Modifier.isPublic(m.getModifiers())) {
            throw new IllegalStateException("Form getter must be public: " + m);
        }
    }
}

Prevention

When it happens

Trigger: Using a class as a multipart/@RestForm output type where a field's getter (found via class hierarchy lookup) is protected, private or package-private while field access is not enabled for that field.

Common situations: Base classes with protected getters reused in multipart forms; Lombok generating non-public accessors via custom settings; tightening visibility during refactoring.

Related errors


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