{"record":{"id":"8611dd1c5675dd36","repo":"apache/dubbo","slug":"cls-getname-generic-type-undefined","errorCode":null,"errorMessage":"${cls.getName()} generic type undefined!","messagePattern":"(.+?) generic type undefined!","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/utils/ReflectUtils.java","lineNumber":294,"sourceCode":"            Object genericClass = parameterizedType.getActualTypeArguments()[i];\n\n            // handle nested generic type\n            if (genericClass instanceof ParameterizedType) {\n                return (Class<?>) ((ParameterizedType) genericClass).getRawType();\n            }\n\n            // handle array generic type\n            if (genericClass instanceof GenericArrayType) {\n                return (Class<?>) ((GenericArrayType) genericClass).getGenericComponentType();\n            }\n\n            // Requires JDK 7 or higher, Foo<int[]> is no longer GenericArrayType\n            if (((Class) genericClass).isArray()) {\n                return ((Class) genericClass).getComponentType();\n            }\n            return (Class<?>) genericClass;\n        } catch (Throwable e) {\n            throw new IllegalArgumentException(cls.getName() + \" generic type undefined!\", e);\n        }\n    }\n\n    /**\n     * get method name.\n     * \"void do(int)\", \"void do()\", \"int do(java.lang.String,boolean)\"\n     *\n     * @param m method.\n     * @return name.\n     */\n    public static String getName(final Method m) {\n        StringBuilder ret = new StringBuilder();\n        ret.append(getName(m.getReturnType())).append(' ');\n        ret.append(m.getName()).append('(');\n        Class<?>[] parameterTypes = m.getParameterTypes();\n        for (int i = 0; i < parameterTypes.length; i++) {\n            if (i > 0) {\n                ret.append(',');","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ReflectUtils.java#L276-L312","documentation":"ReflectUtils.getGenericClassType attempts to extract the raw Class from a Type (handling GenericArrayType, array Class, and plain Class). If any Throwable is thrown during this extraction (class cast, null, resolution failure), it wraps the cause in an IllegalArgumentException stating the class name's generic type is undefined. This signals that the generic type parameter cannot be resolved to a concrete class.","triggerScenarios":"Calling getGenericClassType on a class whose generic type information is incomplete or erases to an unresolvable form — e.g. a raw-typed collection, a TypeVariable with no bound, or a class loaded without generic signature info (legacy bytecode). The try-catch catches Throwable, so even ClassCastExceptions from unsafe casts trigger it.","commonSituations":"A Dubbo service interface that uses raw types (e.g. 'List' without '<>') or complex nested generics where the type erasure prevents resolution. Also when the class was compiled by an old or non-standard compiler that strips generic signatures, or when a TypeVariable without a concrete bound is encountered in a provider/consumer interface.","solutions":["Specify concrete generic types in the service interface instead of raw types (e.g. 'List<String>' not 'List').","If using TypeVariables, ensure they have concrete bounds or are resolved at the call site.","Check the wrapped cause in the exception — it reveals the specific extraction failure.","For collections of POJOs in generic RPC, define explicit concrete types rather than relying on runtime resolution."],"exampleFix":"// before\npublic interface MyService {\n    List getData(); // raw type\n}\n// after\npublic interface MyService {\n    List<String> getData();\n}","handlingStrategy":"validation","validationCode":"// Validate generic type is resolvable before processing\nType genericType = field.getGenericType();\nif (genericType instanceof TypeVariable || genericType instanceof WildcardType) {\n    throw new IllegalStateException(\n        \"Field \" + field.getName() + \" has unresolved generic type: \"\n        + genericType + \". Specify concrete type parameters.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return ReflectUtils.getGenericClassType(cls);\n} catch (IllegalArgumentException e) {\n    logger.warn(\"Cannot resolve generic type for {}, using raw type\", cls.getName());\n    return Object.class; // fallback\n}","preventionTips":["Always parameterize generics with concrete types in Dubbo service interfaces.","Avoid raw types (List without <>) in method signatures that cross the RPC boundary.","Test generic type resolution for all service methods at integration time."],"tags":["reflection","generics","type-resolution","service-interface"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}