quarkusio/quarkus · error · IllegalArgumentException

Unsupported object of type ${object.getClass()}. Supported t

Error message

Unsupported object of type ${object.getClass()}. Supported types are Type, String and Class

What it means

TypeUtils.toGizmoType converts an object representing a Java type (Gizmo Type, class name String, or Class literal) into a Gizmo Type for bytecode generation. If the argument is none of those three types, an IllegalArgumentException naming the actual type is thrown during augmentation.

Source

Thrown at extensions/panache/rest-data-panache/deployment/src/main/java/io/quarkus/rest/data/panache/deployment/utils/TypeUtils.java:41

    private TypeUtils() {

    }

    public static Object primitiveToClass(String type) {
        Class<?> clazz = PRIMITIVE_TO_CLASS_MAPPING.get(type);
        return clazz != null ? clazz : type;
    }

    public static Type toGizmoType(Object object) {
        if (object instanceof Type) {
            return (Type) object;
        } else if (object instanceof String) {
            return Type.classType((String) object);
        } else if (object instanceof Class) {
            return Type.classType((Class<?>) object);
        }

        throw new IllegalArgumentException("Unsupported object of type " + object.getClass()
                + ". Supported types are Type, String and Class");
    }

}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Pass a Class object, a fully-qualified class name String, or a Gizmo/ASM Type instead of the unsupported object.
  2. If you have a java.lang.reflect.Type, unwrap it: for Class use it directly; for ParameterizedType call getRawType().
  3. Convert a class name to Class via Class.forName(...)/loadClass before calling the utility.

Example fix

// before
typeUtils.toGizmoType(genericReflectType); // ParameterizedType
// after
Class<?> raw = (Class<?>) ((ParameterizedType) genericReflectType).getRawType();
typeUtils.toGizmoType(raw);
Defensive patterns

Strategy: type-guard

Type guard

static boolean isGizmoConvertible(Object o) {
    return o instanceof org.objectweb.asm.Type
        || o instanceof String
        || o instanceof Class;
}
// call site:
if (!isGizmoConvertible(obj)) {
    throw new IllegalArgumentException("Expected Type/String/Class, got " + obj.getClass());
}
Type t = toGizmoType(obj);

Prevention

When it happens

Trigger: Deployment time, when internal code (or custom code reusing this util) passes something other than org.objectweb.asm Type, String, or Class to toGizmoType — e.g. a java.lang.reflect.Type, ParameterizedType, or null-derived wrapper from schema resolution.

Common situations: Developer extending/patching the resource generator passes a reflection Type or generic type token instead of a Class/String; refactor swapped an argument order; a custom method implementor feeds an OpenAPI Schema type object into the utility.

Related errors


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