quarkusio/quarkus · error · RuntimeException

Unable to find type arguments of ${interfaceToFind}

Error message

Unable to find type arguments of ${interfaceToFind}

What it means

Types.getActualTypeArgumentsOfAnInterface walks the class hierarchy to find the parameterized types of a given interface. If the class (or its supertypes) does not actually implement the interface with type arguments — or the hierarchy cannot resolve them — findParameterizedTypes returns null and this RuntimeException is thrown.

Source

Thrown at independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/util/types/Types.java:36

/**
 * Type conversions and generic type manipulations
 *
 * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
 * @version $Revision: 1 $
 */
public final class Types {

    /**
     * Given a class and an interfaces, go through the class hierarchy to find the interface and return its type arguments.
     *
     * @param classToSearch class
     * @param interfaceToFind interface to find
     * @return type arguments of the interface
     */
    public static Type[] getActualTypeArgumentsOfAnInterface(Class<?> classToSearch, Class<?> interfaceToFind) {
        Type[] types = findParameterizedTypes(classToSearch, interfaceToFind);
        if (types == null)
            throw new RuntimeException("Unable to find type arguments of " + interfaceToFind);
        return types;
    }

    private static final Type[] EMPTY_TYPE_ARRAY = {};

    /**
     * Search for the given interface or class within the root's class/interface hierarchy.
     * If the searched for class/interface is a generic return an array of real types that fill it out.
     *
     * @param root root class
     * @param searchedFor searched class
     * @return for generic class/interface returns array of real types
     */
    public static Type[] findParameterizedTypes(Class<?> root, Class<?> searchedFor) {
        if (searchedFor.isInterface()) {
            return findInterfaceParameterizedTypes(root, null, searchedFor);
        }
        return findClassParameterizedTypes(root, null, searchedFor);

View on GitHub (pinned to e1c734241f)

Solutions

  1. Confirm classToSearch actually implements interfaceToFind with concrete type arguments (write it as class Foo implements Bar<String>)
  2. Check the interface is on the classpath and spelled correctly (FQN match)
  3. Insert the parameterized interface on an intermediate class if resolution via complex generics fails
  4. Use findParameterizedTypes directly and handle null instead of the throwing wrapper

Example fix

// before
class MyResource implements Handler {} // raw
Types.getActualTypeArgumentsOfAnInterface(MyResource.class, Handler.class); // throws
// after
class MyResource implements Handler<Entity> {}
Types.getActualTypeArgumentsOfAnInterface(MyResource.class, Handler.class); // OK
Defensive patterns

Strategy: validation

Validate before calling

static <T, I> boolean implementsInterface(Class<T> cls, Class<I> iface) {
    for (Class<?> c = cls; c != null; c = c.getSuperclass()) {
        for (Class<?> i : c.getInterfaces()) {
            if (i == iface) return true;
        }
    }
    return false;
}
// guard: if (!implementsInterface(cls, iface)) handle before calling Types method

Try / catch

try {
    Type[] args = Types.getActualTypeArgumentsOfAnInterface(clazz, iface);
} catch (RuntimeException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Unable to find type arguments")) {
    log.warnf("%s does not parameterize %s", clazz, iface);
    args = null; // handle missing configuration
    } else throw e;
}

Prevention

When it happens

Trigger: Calling getActualTypeArgumentsOfAnInterface(classToSearch, interfaceToFind) where classToSearch does not directly or indirectly implement interfaceToFind, or implements it only via a raw/non-parameterized path that findParameterizedTypes cannot resolve.

Common situations: Assuming a resource class implements e.g. RESTService CRUD interface after refactoring the interface name or generics; using the method on classes implementing the interface only through proxies or generated subclasses; mismatched generic arity after version changes.

Related errors


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