{"record":{"id":"5e3e2be4c917caa4","repo":"quarkusio/quarkus","slug":"unable-to-find-type-arguments-of-interfacetofind","errorCode":null,"errorMessage":"Unable to find type arguments of ${interfaceToFind}","messagePattern":"Unable to find type arguments of (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/util/types/Types.java","lineNumber":36,"sourceCode":"/**\n * Type conversions and generic type manipulations\n *\n * @author <a href=\"mailto:bill@burkecentral.com\">Bill Burke</a>\n * @version $Revision: 1 $\n */\npublic final class Types {\n\n    /**\n     * Given a class and an interfaces, go through the class hierarchy to find the interface and return its type arguments.\n     *\n     * @param classToSearch class\n     * @param interfaceToFind interface to find\n     * @return type arguments of the interface\n     */\n    public static Type[] getActualTypeArgumentsOfAnInterface(Class<?> classToSearch, Class<?> interfaceToFind) {\n        Type[] types = findParameterizedTypes(classToSearch, interfaceToFind);\n        if (types == null)\n            throw new RuntimeException(\"Unable to find type arguments of \" + interfaceToFind);\n        return types;\n    }\n\n    private static final Type[] EMPTY_TYPE_ARRAY = {};\n\n    /**\n     * Search for the given interface or class within the root's class/interface hierarchy.\n     * If the searched for class/interface is a generic return an array of real types that fill it out.\n     *\n     * @param root root class\n     * @param searchedFor searched class\n     * @return for generic class/interface returns array of real types\n     */\n    public static Type[] findParameterizedTypes(Class<?> root, Class<?> searchedFor) {\n        if (searchedFor.isInterface()) {\n            return findInterfaceParameterizedTypes(root, null, searchedFor);\n        }\n        return findClassParameterizedTypes(root, null, searchedFor);","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/util/types/Types.java#L18-L54","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm classToSearch actually implements interfaceToFind with concrete type arguments (write it as class Foo implements Bar<String>)","Check the interface is on the classpath and spelled correctly (FQN match)","Insert the parameterized interface on an intermediate class if resolution via complex generics fails","Use findParameterizedTypes directly and handle null instead of the throwing wrapper"],"exampleFix":"// before\nclass MyResource implements Handler {} // raw\nTypes.getActualTypeArgumentsOfAnInterface(MyResource.class, Handler.class); // throws\n// after\nclass MyResource implements Handler<Entity> {}\nTypes.getActualTypeArgumentsOfAnInterface(MyResource.class, Handler.class); // OK","handlingStrategy":"validation","validationCode":"static <T, I> boolean implementsInterface(Class<T> cls, Class<I> iface) {\n    for (Class<?> c = cls; c != null; c = c.getSuperclass()) {\n        for (Class<?> i : c.getInterfaces()) {\n            if (i == iface) return true;\n        }\n    }\n    return false;\n}\n// guard: if (!implementsInterface(cls, iface)) handle before calling Types method","typeGuard":null,"tryCatchPattern":"try {\n    Type[] args = Types.getActualTypeArgumentsOfAnInterface(clazz, iface);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Unable to find type arguments\")) {\n    log.warnf(\"%s does not parameterize %s\", clazz, iface);\n    args = null; // handle missing configuration\n    } else throw e;\n}","preventionTips":["Always implement the interface with explicit type arguments: implements Handler<Entity>","After refactoring interface names/generics, grep all implementors","Write an arquillian/startup test asserting type-argument resolution for key beans","Use findParameterizedTypes directly when null is an acceptable outcome"],"tags":["generics","reflection","type-erasure"],"backgroundTag":"missing-interface-type-arguments","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}